﻿using System;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Xml;
using Assist;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Mechanical;
using Autodesk.Revit.UI;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;
using YArchitech.Revit;
using YArchitech.Revit.Electric;
using HYElectricCommon;
using HYFamilyLibDataManager;

namespace HYRElectric.Calculate
{
	public partial class DlgIllCalMain : System.Windows.Forms.Form
	{
		[DllImport("user32.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Auto, ExactSpelling = true, SetLastError = true)]
		internal static extern void MoveWindow(IntPtr hwnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);

		public DlgIllCalMain()
		{
			this.InitializeComponent();
		}

		public DlgIllCalMain(UIApplication app)
		{
			string fileName = HYElectricCommon.AssistFunc.GetAppRootPath() + "\\Data\\IlluminanceCal.db3";
			this.dbIllAndPower = new SqliteElectricDatabase(fileName);
			this.electricDB = FamilyLibDatabase.GetSqliteDB(SubjectType.Electric, app.Application.VersionNumber);
			this.m_illCalData = new IllCalData();
			this.m_application = app;
			this.m_document = app.ActiveUIDocument.Document;
			this.InitializeComponent();
			this.dgvRoomData.Controls.Add(this.btnSelArea);
			this.dgvRoomData.Controls.Add(this.cmbDPFSXS);
			this.dgvRoomData.Controls.Add(this.cmbQSBFSXS);
			this.dgvRoomData.Controls.Add(this.cmbQXBFSXS);
			this.dgvRoomData.Controls.Add(this.cmbDMFSXS);
			this.dgvRoomData.Controls.Add(this.btnSelLength);
			this.dgvRoomData.Controls.Add(this.btnIllAndPower);
			this.dgvRoomData.CellEnter += this.dgvRoomData_CellEnter;
			this.dgvRoomData.CellLeave += this.dgvRoomData_CellLeave;
			this.dgvRoomData.Refresh();
			this.ResetcmbDropDownWidth(this.fjlx);
			this.InitCmbQFSXS();
			this.InitCmbDMFSXS();
			this.toolTip1.SetToolTip(this.lblGYMC, this.lblGYMC.Text);
		}

		private void DlgIllCalMain_Shown(object sender, EventArgs e)
		{
			this.RefreshDataGridView();
		}

		private void DlgIllCalMain_FormClosed(object sender, FormClosedEventArgs e)
		{
		}

		private void dgvRoomData_CellContentClick(object sender, DataGridViewCellEventArgs e)
		{
		}

		private void ComboBox_SelectedIndexChanged(object sender, EventArgs e)
		{
			if (sender != null)
			{
                System.Windows.Forms.ComboBox comboBox = (System.Windows.Forms.ComboBox)sender;
				if (comboBox != null)
				{
					this.m_illCalData.activeDGVRowData.sFJLX = comboBox.SelectedItem.ToString();
					if (!this.m_illCalData.activeDGVRowData.room.IsHasBoundary())
					{
						return;
					}
					this.m_illCalData.activeDGVRowData.arPtRoom = CalUtility.GetRoomKeyPoint(this.m_application, this.m_illCalData.activeDGVRowData.room, this.m_illCalData.activeDGVRowData.sFJLX);
					this.ResetRowColEnable();
				}
			}
		}

		private void dgvRoomData_CellEnter(object sender, DataGridViewCellEventArgs e)
		{
			if (this.m_illCalData.arDGVData.Count <= 0)
			{
				return;
			}
			int rowIndex = e.RowIndex;
			this.m_illCalData.activeDGVRowData = this.m_illCalData.arDGVData.ElementAt(rowIndex);
			DataGridViewCell dataGridViewCell = this.dgvRoomData.Rows[e.RowIndex].Cells[e.ColumnIndex];
            System.Drawing.Rectangle cellDisplayRectangle = this.dgvRoomData.GetCellDisplayRectangle(dataGridViewCell.ColumnIndex, dataGridViewCell.RowIndex, true);
			if (e.ColumnIndex == 4)
			{
                System.Drawing.Point location = cellDisplayRectangle.Location;
				location.X = location.X + cellDisplayRectangle.Width - this.btnSelArea.Width;
				this.btnSelArea.Location = location;
				this.m_illCalData.arDGVData.ElementAt(rowIndex).dFJMJ = (double)dataGridViewCell.Value;
				return;
			}
			if (e.ColumnIndex == 8)
			{
				this.cmbDPFSXS.Location = cellDisplayRectangle.Location;
				this.cmbDPFSXS.Size = cellDisplayRectangle.Size;
				this.comfirmComboBoxValue(this.cmbDPFSXS, (string)dataGridViewCell.Value);
				this.cmbDPFSXS.Visible = true;
				return;
			}
			if (e.ColumnIndex == 9)
			{
				this.cmbQSBFSXS.Location = cellDisplayRectangle.Location;
				this.cmbQSBFSXS.Size = cellDisplayRectangle.Size;
				this.comfirmComboBoxValue(this.cmbQSBFSXS, (string)dataGridViewCell.Value);
				this.cmbQSBFSXS.Visible = true;
				return;
			}
			if (e.ColumnIndex == 10)
			{
				this.cmbQXBFSXS.Location = cellDisplayRectangle.Location;
				this.cmbQXBFSXS.Size = cellDisplayRectangle.Size;
				this.comfirmComboBoxValue(this.cmbQXBFSXS, (string)dataGridViewCell.Value);
				this.cmbQXBFSXS.Visible = true;
				return;
			}
			if (e.ColumnIndex == 11)
			{
				this.cmbDMFSXS.Location = cellDisplayRectangle.Location;
				this.cmbDMFSXS.Size = cellDisplayRectangle.Size;
				this.comfirmComboBoxValue(this.cmbDMFSXS, (string)dataGridViewCell.Value);
				this.cmbDMFSXS.Visible = true;
				return;
			}
			if (e.ColumnIndex == 14)
			{
                System.Drawing.Point location2 = cellDisplayRectangle.Location;
				location2.X = location2.X + cellDisplayRectangle.Width - this.btnIllAndPower.Width;
				this.btnIllAndPower.Location = location2;
				this.btnIllAndPower.Visible = true;
				return;
			}
			if (e.ColumnIndex == 15)
			{
                System.Drawing.Point location3 = cellDisplayRectangle.Location;
				location3.X = location3.X + cellDisplayRectangle.Width - this.btnIllAndPower.Width;
				this.btnIllAndPower.Location = location3;
				this.btnIllAndPower.Visible = true;
			}
		}

		private void dgvRoomData_CellLeave(object sender, DataGridViewCellEventArgs e)
		{
			if (this.m_illCalData.arDGVData.Count <= 0)
			{
				return;
			}
			int rowIndex = e.RowIndex;
			DataGridViewCell dataGridViewCell = this.dgvRoomData.Rows[e.RowIndex].Cells[e.ColumnIndex];
			if (e.ColumnIndex == 4)
			{
				dataGridViewCell.Value = this.m_illCalData.arDGVData.ElementAt(rowIndex).dFJMJ;
				this.btnSelArea.Visible = false;
			}
		}

		private void dgvRoomData_CellValueChanged(object sender, DataGridViewCellEventArgs e)
		{
			if (this.m_illCalData.arDGVData.Count <= 0)
			{
				return;
			}
			int rowIndex = e.RowIndex;
			this.m_illCalData.activeDGVRowData = this.m_illCalData.arDGVData.ElementAt(rowIndex);
			DataGridViewCell dataGridViewCell = this.dgvRoomData.Rows[e.RowIndex].Cells[e.ColumnIndex];
			if (e.ColumnIndex == 5)
			{
				this.m_illCalData.activeDGVRowData.dFJGD = Convert.ToDouble(dataGridViewCell.Value);
				this.CalUseFactor();
				return;
			}
			if (e.ColumnIndex == 6)
			{
				this.m_illCalData.activeDGVRowData.dGZMGD = Convert.ToDouble(dataGridViewCell.Value);
				this.CalUseFactor();
				return;
			}
			if (e.ColumnIndex == 7)
			{
				if (Convert.ToDouble(dataGridViewCell.Value) > this.m_illCalData.activeDGVRowData.dFJGD)
				{
					MessageBox.Show("安装高度必须小于或等于空间高度，请重新修改！", "盈建科提示");
					dataGridViewCell.Value = this.m_illCalData.activeDGVRowData.dAZGD;
					return;
				}
				this.m_illCalData.activeDGVRowData.dAZGD = Convert.ToDouble(dataGridViewCell.Value);
				this.CalUseFactor();
				return;
			}
			else
			{
				if (e.ColumnIndex == 12)
				{
					this.m_illCalData.activeDGVRowData.dCMJ = Convert.ToDouble(dataGridViewCell.Value);
					this.CalUseFactor();
					return;
				}
				if (e.ColumnIndex == 13)
				{
					this.m_illCalData.activeDGVRowData.dCFSXS = Convert.ToDouble(dataGridViewCell.Value);
					this.CalUseFactor();
				}
				return;
			}
		}

		private void dgvRoomData_CellEndEdit(object sender, DataGridViewCellEventArgs e)
		{
			this.EditingControl.KeyPress -= this.EditingControl_KeyPress;
			this.EditingControl.TextChanged -= this.EditingControl_TextChanged;
			if (this.m_illCalData.arDGVData.Count <= 0)
			{
				return;
			}
			int rowIndex = e.RowIndex;
			this.m_illCalData.activeDGVRowData = this.m_illCalData.arDGVData.ElementAt(rowIndex);
			DataGridViewCell dataGridViewCell = this.dgvRoomData.Rows[e.RowIndex].Cells[e.ColumnIndex];
			if (e.ColumnIndex != 3)
			{
				if (e.ColumnIndex == 8)
				{
					this.CheckingForValid(rowIndex, dataGridViewCell);
					this.cmbDPFSXS.Visible = false;
					this.CalUseFactor();
					return;
				}
				if (e.ColumnIndex == 9)
				{
					this.CheckingForValid(rowIndex, dataGridViewCell);
					this.cmbQSBFSXS.Visible = false;
					this.CalUseFactor();
					return;
				}
				if (e.ColumnIndex == 10)
				{
					this.CheckingForValid(rowIndex, dataGridViewCell);
					this.cmbQXBFSXS.Visible = false;
					this.CalUseFactor();
					return;
				}
				if (e.ColumnIndex == 11)
				{
					this.CheckingForValid(rowIndex, dataGridViewCell);
					this.cmbDMFSXS.Visible = false;
					this.CalUseFactor();
					return;
				}
				if (e.ColumnIndex == 14)
				{
					dataGridViewCell.Value = this.m_illCalData.arDGVData.ElementAt(rowIndex).dPJZD;
					this.btnIllAndPower.Visible = false;
					return;
				}
				if (e.ColumnIndex == 15)
				{
					dataGridViewCell.Value = this.m_illCalData.arDGVData.ElementAt(rowIndex).dYQGLMD;
					this.btnIllAndPower.Visible = false;
				}
			}
		}

		private void CheckingForValid(int row, DataGridViewCell cell)
		{
			switch (cell.ColumnIndex)
			{
			case 8:
				if (!this.IsNumeric(cell.Value.ToString(), false, false))
				{
					cell.Value = this.m_illCalData.arDGVData.ElementAt(row).dDPFSXS.dValue.ToString();
					return;
				}
				this.m_illCalData.arDGVData.ElementAt(row).dDPFSXS.dValue = Convert.ToDouble(cell.Value);
				return;
			case 9:
				if (!this.IsNumeric(cell.Value.ToString(), false, false))
				{
					cell.Value = this.m_illCalData.arDGVData.ElementAt(row).dSBFSXS.dValue.ToString();
					return;
				}
				this.m_illCalData.arDGVData.ElementAt(row).dSBFSXS.dValue = Convert.ToDouble(cell.Value);
				return;
			case 10:
				if (!this.IsNumeric(cell.Value.ToString(), false, false))
				{
					cell.Value = this.m_illCalData.arDGVData.ElementAt(row).dXBFSXS.dValue.ToString();
					return;
				}
				this.m_illCalData.arDGVData.ElementAt(row).dXBFSXS.dValue = Convert.ToDouble(cell.Value);
				return;
			case 11:
				if (!this.IsNumeric(cell.Value.ToString(), false, false))
				{
					cell.Value = this.m_illCalData.arDGVData.ElementAt(row).dDMFSXS.dValue.ToString();
					return;
				}
				this.m_illCalData.arDGVData.ElementAt(row).dDMFSXS.dValue = Convert.ToDouble(cell.Value);
				return;
			default:
				return;
			}
		}

		private void dgvRoomData_Scroll(object sender, ScrollEventArgs e)
		{
			this.btnSelArea.Visible = false;
			this.cmbDPFSXS.Visible = false;
			this.cmbQSBFSXS.Visible = false;
			this.cmbQXBFSXS.Visible = false;
			this.cmbDMFSXS.Visible = false;
			this.btnSelLength.Visible = false;
			this.btnIllAndPower.Visible = false;
		}

		private void dgvRoomData_ColumnWidthChanged(object sender, DataGridViewColumnEventArgs e)
		{
			this.btnSelArea.Visible = false;
			this.cmbDPFSXS.Visible = false;
			this.cmbQSBFSXS.Visible = false;
			this.cmbQXBFSXS.Visible = false;
			this.cmbDMFSXS.Visible = false;
			this.btnSelLength.Visible = false;
			this.btnIllAndPower.Visible = false;
		}

		private void btnSelArea_Click(object sender, EventArgs e)
		{
			this.m_nDlgRstType = 0;
			this.m_nSelRoomType = 1;
		}

		private void btnSelLength_Click(object sender, EventArgs e)
		{
		}

		private void btnIllAndPower_Click(object sender, EventArgs e)
		{
			int rowIndex = this.dgvRoomData.CurrentCell.RowIndex;
			using (DlgSelIllAndPower dlgSelIllAndPower = new DlgSelIllAndPower(this.dbIllAndPower))
			{
				if (dlgSelIllAndPower.ShowDialog() == DialogResult.OK)
				{
					this.dgvRoomData.Rows[rowIndex].Cells[14].Value = dlgSelIllAndPower.m_IllAndPowerData.dZDBZ;
					this.dgvRoomData.Rows[rowIndex].Cells[15].Value = dlgSelIllAndPower.m_IllAndPowerData.dXXZ;
					this.m_illCalData.activeDGVRowData.dPJZD = dlgSelIllAndPower.m_IllAndPowerData.dZDBZ;
					this.m_illCalData.activeDGVRowData.dYQGLMD = dlgSelIllAndPower.m_IllAndPowerData.dXXZ;
					this.m_illCalData.activeDGVRowData.sJZWLX = dlgSelIllAndPower.m_IllAndPowerData.sJZWLX;
					this.m_illCalData.activeDGVRowData.sCSLX = dlgSelIllAndPower.m_IllAndPowerData.sCSLX;
					this.btnIllAndPower.Parent.Focus();
					this.dgvRoomData.RefreshEdit();
				}
			}
		}

		private void tsbJSSZ_Click(object sender, EventArgs e)
		{
		}

		private void tsbDJSJK_Click(object sender, EventArgs e)
		{
			new DlgDatabaseManager(this.dbIllAndPower).ShowDialog();
		}

		private void tsbAddRoom_Click(object sender, EventArgs e)
		{
			this.m_nDlgRstType = 0;
			base.DialogResult = DialogResult.OK;
		}

		private void tsbMultiAddRoom_Click(object sender, EventArgs e)
		{
			this.m_nDlgRstType = 2;
			base.DialogResult = DialogResult.OK;
		}

		private void tsbAddAllRoom_Click(object sender, EventArgs e)
		{
			this.m_nDlgRstType = 3;
			base.DialogResult = DialogResult.OK;
		}

		private void tsbCopyRoom_Click(object sender, EventArgs e)
		{
		}

		private void tsbDelRoom_Click(object sender, EventArgs e)
		{
			if (MessageBox.Show("确定要删除空间吗?", "盈建科提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK && this.dgvRoomData.SelectedRows.Count == 1)
			{
				int num = this.dgvRoomData.CurrentRow.Index;
				if (num >= 0)
				{
					this.m_illCalData.arDGVData.RemoveAt(num);
					for (int i = 0; i < this.m_illCalData.arDGVData.Count; i++)
					{
						this.m_illCalData.arDGVData[i].nIndex = i + 1;
					}
					this.RefreshDataGridView();
					if (this.m_illCalData.arDGVData.Count > 0)
					{
						int num2 = this.dgvRoomData.Rows.Count - 1;
						this.dgvRoomData.Rows[num2].Selected = true;
						this.dgvRoomData.CurrentCell = this.dgvRoomData.Rows[num2].Cells[0];
						this.m_illCalData.activeDGVRowData = this.m_illCalData.arDGVData.Last<DGVRowData>();
					}
				}
				this.btnSelArea.Visible = false;
				this.cmbDPFSXS.Visible = false;
				this.cmbQSBFSXS.Visible = false;
				this.cmbQXBFSXS.Visible = false;
				this.cmbDMFSXS.Visible = false;
				this.btnSelLength.Visible = false;
				this.btnIllAndPower.Visible = false;
			}
		}

		private void tsbMultiModify_Click(object sender, EventArgs e)
		{
			using (DlgColumnModify dlgColumnModify = new DlgColumnModify(this.dbIllAndPower))
			{
				if (dlgColumnModify.ShowDialog() == DialogResult.OK)
				{
					foreach (object obj in this.dgvRoomData.SelectedRows)
					{
						int num = ((DataGridViewRow)obj).Index;
						this.m_illCalData.arDGVData.ElementAt(num).dFJGD = dlgColumnModify.m_MultiData.dFJGD;
						this.m_illCalData.arDGVData.ElementAt(num).dGZMGD = dlgColumnModify.m_MultiData.dGZMGD;
						this.m_illCalData.arDGVData.ElementAt(num).dAZGD = dlgColumnModify.m_MultiData.dAZGD;
						this.m_illCalData.arDGVData.ElementAt(num).dCFSXS = dlgColumnModify.m_MultiData.dCFSXS;
						this.m_illCalData.arDGVData.ElementAt(num).dDPFSXS = dlgColumnModify.m_MultiData.dDPFSXS;
						this.m_illCalData.arDGVData.ElementAt(num).dXBFSXS = dlgColumnModify.m_MultiData.dXBFSXS;
						this.m_illCalData.arDGVData.ElementAt(num).dSBFSXS = dlgColumnModify.m_MultiData.dSBFSXS;
						this.m_illCalData.arDGVData.ElementAt(num).dDMFSXS = dlgColumnModify.m_MultiData.dDMFSXS;
						this.m_illCalData.arDGVData.ElementAt(num).dPJZD = dlgColumnModify.m_MultiData.dPJZD;
						this.m_illCalData.arDGVData.ElementAt(num).dYQGLMD = dlgColumnModify.m_MultiData.dYQGLMD;
						this.m_illCalData.arDGVData.ElementAt(num).sJZWLX = dlgColumnModify.m_MultiData.sJZWLX;
						this.m_illCalData.arDGVData.ElementAt(num).sCSLX = dlgColumnModify.m_MultiData.sCSLX;
					}
					this.RefreshDataGridView();
				}
			}
		}

		private void tsbWord_Click(object sender, EventArgs e)
		{
			new WriteWord
			{
				m_illCalData = this.m_illCalData
			}.Run();
		}

		private void tsbSave_Click(object sender, EventArgs e)
		{
			this.WriteXml();
		}

		private void tsbLoad_Click(object sender, EventArgs e)
		{
			this.ReadXML();
			this.RefreshDataGridView();
			this.InitCmbWHXS();
			this.InitCmbDJLX();
			this.InitCmbDJMC();
			this.InitCmbSCCJ();
			this.InitCmbGYXH();
			if (this.m_illCalData.arDGVData.Count > 0)
			{
				int num = this.dgvRoomData.Rows.Count - 1;
				this.dgvRoomData.Rows[num].Selected = true;
				this.dgvRoomData.CurrentCell = this.dgvRoomData.Rows[num].Cells[0];
				this.m_illCalData.activeDGVRowData = this.m_illCalData.arDGVData.Last<DGVRowData>();
				this.RefreshCurrentDJCS();
				this.RefreshCurrentGYCS();
				this.RefreshCurrentLayoutData();
				this.RefreshCurrentCalData();
				this.ResetRowColEnable();
				this.CalUseFactor();
			}
		}

		private int GetFamilyFromLib(string familyName, ref DbFamily df)
		{
			DbCategory dbCategory = this.electricDB.CategoryTable["无吊顶"];
			if (dbCategory != null)
			{
				foreach (DbFamily dbFamily in dbCategory.GetAllFamilies(true, CheckType.All))
				{
					if (dbFamily.Name.Equals(familyName))
					{
						df = dbFamily;
						return 0;
					}
				}
			}
			DbCategory dbCategory2 = this.electricDB.CategoryTable["有吊顶"];
			if (dbCategory2 != null)
			{
				foreach (DbFamily dbFamily2 in dbCategory2.GetAllFamilies(true, CheckType.All))
				{
					if (dbFamily2.Name.Equals(familyName))
					{
						df = dbFamily2;
						return 1;
					}
				}
			}
			return -1;
		}

		private void btnPlace_Click(object sender, EventArgs e)
		{
			this.m_nDlgRstType = 1;
			this.m_elevation = ((this.tbXDBG.Text == null) ? 0.0 : double.Parse(this.tbXDBG.Text));
		}

		private void btnJSDJTS_Click(object sender, EventArgs e)
		{
			if (this.m_illCalData.activeDGVRowData.dFJMJ <= 0.0)
			{
				MessageBox.Show("空间数据不满足要求，请检查空间数据！", "盈建科提示");
				return;
			}
			if (!this.IsCalDataCorrect())
			{
				return;
			}
			this.m_illCalData.activeDGVRowData.arPtRoom = CalUtility.GetRoomKeyPoint(this.m_application, this.m_illCalData.activeDGVRowData.room, this.m_illCalData.activeDGVRowData.sFJLX);
			if (this.m_illCalData.activeDGVRowData.arPtRoom == null)
			{
				return;
			}
			int nDJNum = (int)(this.m_illCalData.activeDGVRowData.dPJZD * this.m_illCalData.activeDGVRowData.dFJMJ / (this.m_illCalData.activeDGVRowData.gycsData.dTGL * (double)this.m_illCalData.activeDGVRowData.gycsData.nGYSL * this.m_illCalData.activeDGVRowData.djcsData.dLYXS * this.m_illCalData.activeDGVRowData.djcsData.dDJWHXS) + 0.5);
			this.m_illCalData.activeDGVRowData.layoutData.nDJNum = nDJNum;
			new CalUtility(this.m_application).CalRoomLayRowAndCol(this.m_illCalData);
			if (this.m_illCalData.activeDGVRowData.sFJLX == "矩形" || this.m_illCalData.activeDGVRowData.sFJLX == "多边形")
			{
				this.m_illCalData.activeDGVRowData.layoutData.nDJNum = this.m_illCalData.activeDGVRowData.layoutData.nRowNum * this.m_illCalData.activeDGVRowData.layoutData.nColNum;
			}
			this.tbJSDJTS.Text = this.m_illCalData.activeDGVRowData.layoutData.nDJNum.ToString();
			if (this.m_illCalData.activeDGVRowData.layoutData.nRowNum < 0 || this.m_illCalData.activeDGVRowData.layoutData.nRowNum > 99 || this.m_illCalData.activeDGVRowData.layoutData.nColNum < 0 || this.m_illCalData.activeDGVRowData.layoutData.nColNum > 99)
			{
				MessageBox.Show("计算所得行列数超出范围，请检查！");
				return;
			}
			this.nudBZHS.Value = this.m_illCalData.activeDGVRowData.layoutData.nRowNum;
			this.nudBZLS.Value = this.m_illCalData.activeDGVRowData.layoutData.nColNum;
			this.cmbDJFX.SelectedIndex = this.m_illCalData.activeDGVRowData.layoutData.nVector;
			this.GetCalResultByLampCount();
		}

		private void btnJHTZ_Click(object sender, EventArgs e)
		{
			this.GetCalResultByLampCount();
		}

		private void dgvRoomData_SelectionChanged(object sender, EventArgs e)
		{
			if (this.dgvRoomData.Rows.Count <= 0 || this.m_illCalData.arDGVData.Count <= 0)
			{
				return;
			}
			if (this.dgvRoomData.SelectedRows.Count == 1)
			{
				this.tsbMultiModify.Enabled = false;
				this.EnableControls(1);
				int num = this.dgvRoomData.CurrentRow.Index;
				this.m_illCalData.activeDGVRowData = this.m_illCalData.arDGVData.ElementAt(num);
				this.RefreshCurrentDJCS();
				this.RefreshCurrentGYCS();
				this.RefreshCurrentLayoutData();
				this.RefreshCurrentCalData();
				this.ResetRowColEnable();
				this.CalUseFactor();
				return;
			}
			if (this.dgvRoomData.SelectedRows.Count > 1)
			{
				this.tsbMultiModify.Enabled = true;
				this.EnableControls(0);
				return;
			}
			this.tsbMultiModify.Enabled = false;
		}

		private void EnableControls(int enableMode)
		{
			if (enableMode == 0)
			{
				this.cmbDJWHXS.Enabled = false;
				this.cmbDJLX.Enabled = false;
				this.cmbDJMC.Enabled = false;
				this.tbDJXH.Enabled = false;
				this.tbDJXL.Enabled = false;
				this.tbLYXS.Enabled = false;
				this.tbDJAA.Enabled = false;
				this.tbDJBB.Enabled = false;
				this.cmbSCCJ.Enabled = false;
				this.cmbGYXH.Enabled = false;
				this.tbGYSL.Enabled = false;
				this.nudBZHS.Enabled = false;
				this.nudBZLS.Enabled = false;
				this.cmbDJFX.Enabled = false;
				this.nudBJB.Enabled = false;
				this.tbXDBG.Enabled = false;
				this.btnPlace.Enabled = false;
				this.tbZDZ.Enabled = false;
				this.tbGLMD.Enabled = false;
				this.tbHSGLMD.Enabled = false;
				this.tbGLMDJH.Enabled = false;
				this.tbJSAA.Enabled = false;
				this.tbJSBB.Enabled = false;
				this.tbZDJH.Enabled = false;
				this.nudZLQNum.Enabled = false;
				this.nudZLQGL.Enabled = false;
				this.btnJSDJTS.Enabled = false;
				this.tbJSDJTS.Enabled = false;
				this.btnJHTZ.Enabled = false;
				return;
			}
			if (enableMode == 1)
			{
				this.cmbDJWHXS.Enabled = true;
				this.cmbDJLX.Enabled = true;
				this.cmbDJMC.Enabled = true;
				this.tbDJXH.Enabled = true;
				this.tbDJXL.Enabled = true;
				this.tbLYXS.Enabled = true;
				this.tbDJAA.Enabled = true;
				this.tbDJBB.Enabled = true;
				this.cmbSCCJ.Enabled = true;
				this.cmbGYXH.Enabled = true;
				this.tbGYSL.Enabled = true;
				this.nudBZHS.Enabled = true;
				this.nudBZLS.Enabled = true;
				this.cmbDJFX.Enabled = true;
				this.nudBJB.Enabled = true;
				this.tbXDBG.Enabled = true;
				this.btnPlace.Enabled = true;
				this.tbZDZ.Enabled = true;
				this.tbGLMD.Enabled = true;
				this.tbHSGLMD.Enabled = true;
				this.tbGLMDJH.Enabled = true;
				this.tbJSAA.Enabled = true;
				this.tbJSBB.Enabled = true;
				this.tbZDJH.Enabled = true;
				this.nudZLQNum.Enabled = true;
				this.nudZLQGL.Enabled = true;
				this.btnJSDJTS.Enabled = true;
				this.tbJSDJTS.Enabled = true;
				this.btnJHTZ.Enabled = true;
			}
		}

		private void cmbDJWHXS_SelectionChangeCommitted(object sender, EventArgs e)
		{
			this.SaveCurrentDJCS();
			this.SaveCurrentGYCS();
		}

		private void cmbDJLX_SelectionChangeCommitted(object sender, EventArgs e)
		{
			this.InitCmbDJMC();
			this.InitCmbSCCJ();
			this.InitCmbGYXH();
			if (this.cmbDJLX.SelectedItem != null)
			{
				this.lblGYLX.Text = this.cmbDJLX.SelectedItem.ToString();
			}
			this.SaveCurrentDJCS();
			this.SaveCurrentGYCS();
			if (this.cmbDJMC.Items.Count > 0)
			{
				this.CalUseFactor();
				string familyName = this.cmbDJMC.SelectedItem.ToString();
				DbFamily dbFamily = null;
				int familyFromLib = this.GetFamilyFromLib(familyName, ref dbFamily);
				if (familyFromLib == 0)
				{
					this.lblLightType.Text = "无吊顶灯具，可在平面视图中布置！";
					this.lblXDBG.Enabled = true;
					this.tbXDBG.Enabled = true;
					return;
				}
				if (familyFromLib == 1)
				{
					this.lblLightType.Text = "有吊顶灯具，需在天花板平面中布置！";
					this.lblXDBG.Enabled = false;
					this.tbXDBG.Enabled = false;
					return;
				}
				this.lblLightType.Text = "未能从族库中找到族，无法布置！";
			}
		}

		private void cmbDJMC_SelectionChangeCommitted(object sender, EventArgs e)
		{
			this.ResetDJCSByDJMC();
			this.SaveCurrentDJCS();
			this.SaveCurrentGYCS();
			this.CalUseFactor();
			string familyName = this.cmbDJMC.SelectedItem.ToString();
			DbFamily dbFamily = null;
			int familyFromLib = this.GetFamilyFromLib(familyName, ref dbFamily);
			if (familyFromLib == 0)
			{
				this.lblLightType.Text = "无吊顶灯具，可在平面视图中布置！";
				this.lblXDBG.Enabled = true;
				this.tbXDBG.Enabled = true;
				return;
			}
			if (familyFromLib == 1)
			{
				this.lblLightType.Text = "有吊顶灯具，需在天花板平面中布置！";
				this.lblXDBG.Enabled = false;
				this.tbXDBG.Enabled = false;
				return;
			}
			this.lblLightType.Text = "未能从族库中找到族，无法布置！";
		}

		private void cmbSCCJ_SelectionChangeCommitted(object sender, EventArgs e)
		{
			this.InitCmbGYXH();
			this.ResetGYCSByGYXH();
			this.SaveCurrentGYCS();
		}

		private void cmbGYXH_SelectionChangeCommitted(object sender, EventArgs e)
		{
			this.ResetGYCSByGYXH();
			this.SaveCurrentGYCS();
		}

		private void cmbGYXH_SelectedIndexChanged(object sender, EventArgs e)
		{
		}

		private void cmbDJFX_SelectedIndexChanged(object sender, EventArgs e)
		{
			this.m_illCalData.activeDGVRowData.layoutData.nVector = this.cmbDJFX.SelectedIndex;
		}

		private void tbDJXL_TextChanged(object sender, EventArgs e)
		{
			this.SaveCurrentDJCS();
		}

		private void tbLYXS_TextChanged(object sender, EventArgs e)
		{
			this.SaveCurrentDJCS();
		}

		private void tbDJAA_TextChanged(object sender, EventArgs e)
		{
			this.SaveCurrentDJCS();
		}

		private void tbDJBB_TextChanged(object sender, EventArgs e)
		{
			this.SaveCurrentDJCS();
		}

		private void tbGYSL_TextChanged(object sender, EventArgs e)
		{
			this.SaveCurrentGYCS();
		}

		private void nudZLQNum_ValueChanged(object sender, EventArgs e)
		{
			this.m_illCalData.activeDGVRowData.djcsData.nZLQNum = Convert.ToInt32(this.nudZLQNum.Value);
		}

		private void nudZLQGL_ValueChanged(object sender, EventArgs e)
		{
			this.m_illCalData.activeDGVRowData.djcsData.dZLQGL = Convert.ToDouble(this.nudZLQGL.Value);
		}

		private void tbJSDJTS_TextChanged(object sender, EventArgs e)
		{
			this.m_illCalData.activeDGVRowData.layoutData.nDJNum = int.Parse(this.tbJSDJTS.Text);
			this.GetAABBValAndSetVal();
			this.GetCalResultByLampCount();
		}

		private void nudBZHS_ValueChanged(object sender, EventArgs e)
		{
			this.m_illCalData.activeDGVRowData.layoutData.nRowNum = Convert.ToInt32(this.nudBZHS.Value);
			this.ModifyLightVal();
		}

		private void nudBZLS_ValueChanged(object sender, EventArgs e)
		{
			this.m_illCalData.activeDGVRowData.layoutData.nColNum = Convert.ToInt32(this.nudBZLS.Value);
			this.ModifyLightVal();
		}

		private void nudBJB_ValueChanged(object sender, EventArgs e)
		{
			this.m_illCalData.activeDGVRowData.layoutData.dBJB = Convert.ToDouble(this.nudBJB.Value);
		}

		private void tbZDZ_TextChanged(object sender, EventArgs e)
		{
			this.m_illCalData.activeDGVRowData.calResultData.dZDZ = double.Parse(this.tbZDZ.Text);
		}

		private void tbGLMD_TextChanged(object sender, EventArgs e)
		{
			this.m_illCalData.activeDGVRowData.calResultData.dGLMD = double.Parse(this.tbGLMD.Text);
		}

		private void tbHSGLMD_TextChanged(object sender, EventArgs e)
		{
			this.m_illCalData.activeDGVRowData.calResultData.dHSGLMD = double.Parse(this.tbHSGLMD.Text);
		}

		private void tbGLMDJH_TextChanged(object sender, EventArgs e)
		{
			this.m_illCalData.activeDGVRowData.calResultData.sGLMDJH = this.tbGLMDJH.Text;
		}

		private void tbJSAA_TextChanged(object sender, EventArgs e)
		{
			this.m_illCalData.activeDGVRowData.calResultData.dAA = double.Parse(this.tbJSAA.Text);
		}

		private void tbJSBB_TextChanged(object sender, EventArgs e)
		{
			this.m_illCalData.activeDGVRowData.calResultData.dBB = double.Parse(this.tbJSBB.Text);
		}

		private void tbZDJH_TextChanged(object sender, EventArgs e)
		{
			this.m_illCalData.activeDGVRowData.calResultData.sZDJYDJH = this.tbZDJH.Text;
		}

        private void comfirmComboBoxValue(YArchitech.Electric.Controls.YJKComboBox com, string cellValue)
		{
			com.SelectedIndex = -1;
			if (cellValue == null)
			{
				com.Text = "";
				return;
			}
			com.Text = cellValue;
		}

		private void CreatePropertyGrid()
		{
			this.OptionsPropertyGrid = new PropertyGrid();
			this.OptionsPropertyGrid.Size = new Size(290, 200);
            System.Drawing.Point location = this.lblZLQGS.Location;
			location.Y += this.lblZLQGS.Height + 5;
			this.OptionsPropertyGrid.Location = location;
			base.Controls.Add(this.OptionsPropertyGrid);
		}

		public void InsertNewRow()
		{
			DGVRowData dgvrowData = new DGVRowData();
			dgvrowData.nIndex = this.dgvRoomData.Rows.Count + 1;
			dgvrowData.dDPFSXS = this.GetFirstComboFSXSData(this.cmbDPFSXS);
			dgvrowData.dSBFSXS = this.GetFirstComboFSXSData(this.cmbQSBFSXS);
			dgvrowData.dXBFSXS = this.GetFirstComboFSXSData(this.cmbQXBFSXS);
			dgvrowData.dDMFSXS = this.GetFirstComboFSXSData(this.cmbDMFSXS);
			this.m_illCalData.arDGVData.Add(dgvrowData);
			this.m_illCalData.activeDGVRowData = this.m_illCalData.arDGVData.Last<DGVRowData>();
			this.RefreshDataGridView();
			int num = this.dgvRoomData.Rows.Count - 1;
			this.dgvRoomData.Rows[num].Selected = true;
			this.dgvRoomData.CurrentCell = this.dgvRoomData.Rows[num].Cells[0];
			this.InitCmbWHXS();
			this.InitCmbDJLX();
			this.InitCmbDJMC();
			this.InitCmbSCCJ();
			this.InitCmbGYXH();
			this.lblGYLX.Text = this.cmbDJLX.SelectedItem.ToString();
			this.InitDJCS();
			this.InitGYCS();
			this.SaveCurrentDJCS();
			this.SaveCurrentGYCS();
			if (this.cmbDJMC.Items.Count > 0)
			{
				this.CalUseFactor();
				string familyName = this.cmbDJMC.SelectedItem.ToString();
				DbFamily dbFamily = null;
				int familyFromLib = this.GetFamilyFromLib(familyName, ref dbFamily);
				if (familyFromLib == 0)
				{
					this.lblLightType.Text = "无吊顶灯具，可在平面视图中布置！";
					this.lblXDBG.Enabled = true;
					this.tbXDBG.Enabled = true;
					return;
				}
				if (familyFromLib == 1)
				{
					this.lblLightType.Text = "有吊顶灯具，需在天花板平面中布置！";
					this.lblXDBG.Enabled = false;
					this.tbXDBG.Enabled = false;
					return;
				}
				this.lblLightType.Text = "未能从族库中找到族，无法布置！";
			}
		}

		private void InitDJCS()
		{
			this.cmbDJWHXS.SelectedIndex = 0;
			this.cmbDJLX.SelectedIndex = 1;
			this.cmbDJMC.SelectedIndex = 0;
			this.ResetDJCSByDJMC();
		}

		private void InitGYCS()
		{
			this.cmbGYXH.SelectedIndex = 0;
			this.ResetGYCSByGYXH();
		}

		private void InitBZCS()
		{
			this.cmbDJFX.SelectedIndex = 0;
		}

		private void ResetDJCSByDJMC()
		{
			string str = this.cmbDJMC.SelectedItem.ToString();
			DataTable dataTable = this.dbIllAndPower.ExecQuery("select [LightSrcCount], [LampStyle], [LampEfficiency], [MaxJGBAA], [MaxJGBBB] from [Lamp] where [LampName] ='" + str + "'");
			if (dataTable != null)
			{
				this.tbGYSL.Text = dataTable.Rows[0][0].ToString();
				this.tbDJXH.Text = dataTable.Rows[0][1].ToString();
				this.tbDJXL.Text = dataTable.Rows[0][2].ToString();
				this.tbDJAA.Text = dataTable.Rows[0][3].ToString();
				this.tbDJBB.Text = dataTable.Rows[0][4].ToString();
			}
		}

		private void ResetGYCSByGYXH()
		{
			string str = null;
			string str2 = this.cmbGYXH.SelectedItem.ToString();
			DataTable dataTable = this.dbIllAndPower.ExecQuery("select [LampName], [LuminousFlux], [LampPower], [LampFactory], [LampTypeID] from [Illuminant] where [LampStyle] ='" + str2 + "'");
			if (dataTable != null)
			{
				this.lblGYMC.Text = dataTable.Rows[0][0].ToString();
				this.toolTip1.SetToolTip(this.lblGYMC, this.lblGYMC.Text);
				this.lblDGYTGL.Text = dataTable.Rows[0][1].ToString();
				this.lblDGYGL.Text = dataTable.Rows[0][2].ToString();
				this.cmbSCCJ.SelectedText = dataTable.Rows[0][3].ToString();
				str = dataTable.Rows[0][4].ToString();
			}
			DataTable dataTable2 = this.dbIllAndPower.ExecQuery("select [LampType] from [LampType] where [LampTypeID] ='" + str + "'");
			if (dataTable2 != null)
			{
				this.lblGYLX.Text = dataTable2.Rows[0][0].ToString();
			}
		}

		private void InitCmbQFSXS()
		{
			this.cmbDPFSXS.Items.Clear();
			this.cmbQXBFSXS.Items.Clear();
			this.cmbQSBFSXS.Items.Clear();
			DataTable dataTable = this.dbIllAndPower.ExecQuery("select [RefFactor], [Describe] from [CeilingRef]");
			if (dataTable != null)
			{
				for (int i = 0; i < dataTable.Rows.Count; i++)
				{
					FSXSData fsxsdata = new FSXSData();
					fsxsdata.sDescribe = dataTable.Rows[i][1].ToString() + " :" + dataTable.Rows[i][0].ToString();
					fsxsdata.dValue = Convert.ToDouble(dataTable.Rows[i][0].ToString());
					this.cmbDPFSXS.Items.Add(fsxsdata);
					this.cmbQXBFSXS.Items.Add(fsxsdata);
					this.cmbQSBFSXS.Items.Add(fsxsdata);
				}
			}
		}

		private void InitCmbDMFSXS()
		{
			this.cmbDMFSXS.Items.Clear();
			DataTable dataTable = this.dbIllAndPower.ExecQuery("select [RefFactor], [Describe] from [GroundRef]");
			if (dataTable != null)
			{
				for (int i = 0; i < dataTable.Rows.Count; i++)
				{
					FSXSData fsxsdata = new FSXSData();
					fsxsdata.sDescribe = dataTable.Rows[i][1].ToString() + " :" + dataTable.Rows[i][0].ToString();
					fsxsdata.dValue = Convert.ToDouble(dataTable.Rows[i][0].ToString());
					this.cmbDMFSXS.Items.Add(fsxsdata);
				}
			}
		}

		private void InitCmbWHXS()
		{
			this.cmbDJWHXS.Items.Clear();
			DataTable dataTable = this.dbIllAndPower.ExecQuery("select [whxs], [Type] from [LampWHXS]");
			if (dataTable != null)
			{
				for (int i = 0; i < dataTable.Rows.Count; i++)
				{
					string item = dataTable.Rows[i][0].ToString() + "|" + dataTable.Rows[i][1].ToString();
					this.cmbDJWHXS.Items.Add(item);
				}
			}
			if (this.cmbDJWHXS.Items.Count > 0)
			{
				this.cmbDJWHXS.SelectedIndex = 0;
			}
		}

		private void InitCmbDJLX()
		{
			this.cmbDJLX.Items.Clear();
			DataTable dataTable = this.dbIllAndPower.ExecQuery("select [LampType] from [LampType]");
			if (dataTable != null)
			{
				for (int i = 0; i < dataTable.Rows.Count; i++)
				{
					string item = dataTable.Rows[i][0].ToString();
					this.cmbDJLX.Items.Add(item);
				}
			}
			if (this.cmbDJLX.Items.Count > 1)
			{
				this.cmbDJLX.SelectedIndex = 1;
			}
		}

		private void InitCmbDJMC()
		{
			this.cmbDJMC.Items.Clear();
			int srcId = this.cmbDJLX.SelectedIndex + 1;
			DataTable dataTable = this.dbIllAndPower.ExecQuery("select [LampName], [LampTypeID] from [Lamp]");
			if (dataTable != null)
			{
				for (int i = 0; i < dataTable.Rows.Count; i++)
				{
					if (this.ContainsLampTypeId(srcId, dataTable.Rows[i][1].ToString()))
					{
						string item = dataTable.Rows[i][0].ToString();
						this.cmbDJMC.Items.Add(item);
					}
				}
			}
			if (this.cmbDJMC.Items.Count > 0)
			{
				this.cmbDJMC.SelectedIndex = 0;
			}
		}

		private void InitCmbSCCJ()
		{
			this.cmbSCCJ.Items.Clear();
			int num = this.cmbDJLX.SelectedIndex + 1;
			DataTable dataTable = this.dbIllAndPower.ExecQuery("select [LampFactory] from [Illuminant] where [LampTypeID] ='" + num.ToString() + "'");
			if (dataTable != null)
			{
				for (int i = 0; i < dataTable.Rows.Count; i++)
				{
					string text = dataTable.Rows[i][0].ToString();
					if (!this.cmbSCCJ.Items.Contains(text))
					{
						this.cmbSCCJ.Items.Add(text);
					}
				}
			}
			if (this.cmbSCCJ.Items.Count > 0)
			{
				this.cmbSCCJ.SelectedIndex = 0;
			}
		}

		private void InitCmbGYXH()
		{
			this.cmbGYXH.Items.Clear();
			int num = this.cmbDJLX.SelectedIndex + 1;
			string text = (this.cmbSCCJ.SelectedIndex >= 0) ? this.cmbSCCJ.Items[this.cmbSCCJ.SelectedIndex].ToString() : null;
			DataTable dataTable = this.dbIllAndPower.ExecQuery(string.Concat(new string[]
			{
				"select [LampStyle] from [Illuminant] where [LampTypeID] ='",
				num.ToString(),
				"' and [LampFactory] ='",
				text,
				"'"
			}));
			if (dataTable != null)
			{
				for (int i = 0; i < dataTable.Rows.Count; i++)
				{
					string text2 = dataTable.Rows[i][0].ToString();
					if (!this.cmbGYXH.Items.Contains(text2))
					{
						this.cmbGYXH.Items.Add(text2);
					}
				}
			}
			if (this.cmbGYXH.Items.Count > 0)
			{
				this.cmbGYXH.SelectedIndex = 0;
			}
		}

        private FSXSData GetFirstComboFSXSData(YArchitech.Electric.Controls.YJKComboBox combo)
		{
			FSXSData result = new FSXSData();
			if (combo.Items.Count > 0)
			{
				result = (FSXSData)combo.Items[0];
			}
			return result;
		}

		private bool ContainsLampTypeId(int srcId, string sDes)
		{
			bool flag = false;
			for (int i = sDes.IndexOf(","); i > 0; i = sDes.IndexOf(","))
			{
				if (Convert.ToInt32(sDes.Substring(0, i)) == srcId)
				{
					flag = true;
					break;
				}
				sDes = sDes.Substring(i + 1);
			}
			if (!flag && Convert.ToInt32(sDes) == srcId)
			{
				flag = true;
			}
			return flag;
		}

        private FSXSData GetFSXSDataByDescribe(YArchitech.Electric.Controls.YJKComboBox com, string sDescribe)
		{
			foreach (object obj in com.Items)
			{
				if (((FSXSData)obj).dValue.ToString() == sDescribe)
				{
					return (FSXSData)obj;
				}
			}
			return null;
		}

		private double GetDJWHXSByDescribe(string sDescribe)
		{
			double result = 0.0;
			if (sDescribe.Length <= 0)
			{
				return result;
			}
			int length = sDescribe.IndexOf("|");
			return Convert.ToDouble(sDescribe.Substring(0, length));
		}

		private void SaveCurrentDJCS()
		{
			try
			{
				if (this.cmbDJWHXS.SelectedItem != null)
				{
					this.m_illCalData.activeDGVRowData.djcsData.dDJWHXS = this.GetDJWHXSByDescribe(this.cmbDJWHXS.SelectedItem.ToString());
				}
				if (this.cmbDJLX.SelectedItem != null)
				{
					this.m_illCalData.activeDGVRowData.djcsData.sDJLX = this.cmbDJLX.SelectedItem.ToString();
				}
				if (this.cmbDJMC.SelectedItem != null)
				{
					this.m_illCalData.activeDGVRowData.djcsData.sDJMC = this.cmbDJMC.SelectedItem.ToString();
				}
				if (this.tbDJXH.Text.Length > 0)
				{
					this.m_illCalData.activeDGVRowData.djcsData.sDJXH = this.tbDJXH.Text;
				}
				if (this.tbDJXL.Text.Length > 0)
				{
					this.m_illCalData.activeDGVRowData.djcsData.dDJXL = Convert.ToDouble(this.tbDJXL.Text);
				}
				if (this.tbLYXS.Text.Length > 0)
				{
					this.m_illCalData.activeDGVRowData.djcsData.dLYXS = Convert.ToDouble(this.tbLYXS.Text);
				}
				if (this.tbDJAA.Text.Length > 0)
				{
					this.m_illCalData.activeDGVRowData.djcsData.dAA = Convert.ToDouble(this.tbDJAA.Text);
				}
				if (this.tbDJBB.Text.Length > 0)
				{
					this.m_illCalData.activeDGVRowData.djcsData.dBB = Convert.ToDouble(this.tbDJBB.Text);
				}
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
		}

		private void RefreshCurrentDJCS()
		{
			try
			{
				this.cmbDJWHXS.SelectedText = this.m_illCalData.activeDGVRowData.djcsData.dDJWHXS.ToString();
				int num = this.cmbDJLX.FindString(this.m_illCalData.activeDGVRowData.djcsData.sDJLX);
				if (num != -1)
				{
					this.cmbDJLX.SelectedIndex = num;
				}
				num = this.cmbDJMC.FindString(this.m_illCalData.activeDGVRowData.djcsData.sDJMC);
				if (num != -1)
				{
					this.cmbDJMC.SelectedIndex = num;
				}
				this.tbDJXH.Text = this.m_illCalData.activeDGVRowData.djcsData.sDJXH;
				this.tbDJXL.Text = this.m_illCalData.activeDGVRowData.djcsData.dDJXL.ToString();
				this.tbLYXS.Text = this.m_illCalData.activeDGVRowData.djcsData.dLYXS.ToString();
				this.tbDJAA.Text = this.m_illCalData.activeDGVRowData.djcsData.dAA.ToString();
				this.tbDJBB.Text = this.m_illCalData.activeDGVRowData.djcsData.dBB.ToString();
				this.nudZLQNum.Value = this.m_illCalData.activeDGVRowData.djcsData.nZLQNum;
				this.nudZLQGL.Value = Convert.ToDecimal(this.m_illCalData.activeDGVRowData.djcsData.dZLQGL.ToString());
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
		}

		private void SaveCurrentGYCS()
		{
			try
			{
				if (this.cmbSCCJ.SelectedItem != null)
				{
					this.m_illCalData.activeDGVRowData.gycsData.sSCCJ = this.cmbSCCJ.SelectedItem.ToString();
				}
				if (this.lblGYLX.Text.Length > 0)
				{
					this.m_illCalData.activeDGVRowData.gycsData.sGYLX = this.lblGYLX.Text;
				}
				if (this.cmbGYXH.SelectedItem != null)
				{
					this.m_illCalData.activeDGVRowData.gycsData.sGYXH = this.cmbGYXH.SelectedItem.ToString();
				}
				if (this.lblGYLX.Text.Length > 0)
				{
					this.m_illCalData.activeDGVRowData.gycsData.sGYMC = this.lblGYMC.Text;
				}
				if (this.tbGYSL.Text.Length > 0)
				{
					this.m_illCalData.activeDGVRowData.gycsData.nGYSL = Convert.ToInt32(this.tbGYSL.Text);
				}
				if (this.lblDGYGL.Text.Length > 0)
				{
					this.m_illCalData.activeDGVRowData.gycsData.dGL = Convert.ToDouble(this.lblDGYGL.Text);
				}
				if (this.lblDGYTGL.Text.Length > 0)
				{
					this.m_illCalData.activeDGVRowData.gycsData.dTGL = Convert.ToDouble(this.lblDGYTGL.Text);
				}
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
		}

		private void RefreshCurrentGYCS()
		{
			try
			{
				int num = this.cmbSCCJ.FindString(this.m_illCalData.activeDGVRowData.gycsData.sSCCJ);
				if (num != -1)
				{
					this.cmbSCCJ.SelectedIndex = num;
				}
				this.InitCmbGYXH();
				this.lblGYLX.Text = this.m_illCalData.activeDGVRowData.gycsData.sGYLX;
				num = this.cmbGYXH.FindString(this.m_illCalData.activeDGVRowData.gycsData.sGYXH);
				if (num != -1)
				{
					this.cmbGYXH.SelectedIndex = num;
				}
				this.lblGYMC.Text = this.m_illCalData.activeDGVRowData.gycsData.sGYMC;
				this.toolTip1.SetToolTip(this.lblGYMC, this.lblGYMC.Text);
				this.lblDGYGL.Text = this.m_illCalData.activeDGVRowData.gycsData.dGL.ToString();
				this.lblDGYTGL.Text = this.m_illCalData.activeDGVRowData.gycsData.dTGL.ToString();
				this.tbGYSL.Text = this.m_illCalData.activeDGVRowData.gycsData.nGYSL.ToString();
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
		}

		private void SaveCurrentLayoutData()
		{
			try
			{
				this.m_illCalData.activeDGVRowData.layoutData.nDJNum = Convert.ToInt32(this.tbJSDJTS.Text);
				this.m_illCalData.activeDGVRowData.layoutData.nRowNum = Convert.ToInt32(this.nudBZHS.Value);
				this.m_illCalData.activeDGVRowData.layoutData.nColNum = Convert.ToInt32(this.nudBZLS.Value);
				this.m_illCalData.activeDGVRowData.layoutData.nVector = this.cmbDJFX.SelectedIndex;
				this.m_illCalData.activeDGVRowData.layoutData.dBJB = Convert.ToDouble(this.nudBJB.Value);
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
		}

		private void RefreshCurrentLayoutData()
		{
			try
			{
				this.tbJSDJTS.Text = this.m_illCalData.activeDGVRowData.layoutData.nDJNum.ToString();
				this.nudBZHS.Value = this.m_illCalData.activeDGVRowData.layoutData.nRowNum;
				this.nudBZLS.Value = this.m_illCalData.activeDGVRowData.layoutData.nColNum;
				if (this.m_illCalData.activeDGVRowData.layoutData.nVector != -1)
				{
					this.cmbDJFX.SelectedIndex = this.m_illCalData.activeDGVRowData.layoutData.nVector;
				}
				this.nudBJB.Value = Convert.ToDecimal(this.m_illCalData.activeDGVRowData.layoutData.dBJB.ToString());
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
		}

		private void RefreshCurrentCalData()
		{
			try
			{
				CalResultData calResultData = this.m_illCalData.activeDGVRowData.calResultData;
				this.tbZDZ.Text = calResultData.dZDZ.ToString("0.00");
				this.tbGLMD.Text = calResultData.dGLMD.ToString("0.00");
				this.tbHSGLMD.Text = calResultData.dHSGLMD.ToString("0.00");
				this.tbGLMDJH.Text = calResultData.sGLMDJH;
				this.tbJSAA.Text = calResultData.dAA.ToString("0.00");
				this.tbJSBB.Text = calResultData.dBB.ToString("0.00");
				this.tbZDJH.Text = calResultData.sZDJYDJH;
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
		}

		private void ResetRowColEnable()
		{
			ROOMTYPE roomTypeByString = CalUtility.GetRoomTypeByString(this.m_illCalData.activeDGVRowData.sFJLX);
			if (roomTypeByString <= ROOMTYPE.ePoly)
			{
				this.lblCol.Text = "X 列数：";
				this.lblRow.Enabled = true;
				this.nudBZHS.Enabled = true;
				this.lblBJB.Enabled = true;
				this.nudBJB.Enabled = true;
				return;
			}
			if (roomTypeByString - ROOMTYPE.eArc > 2)
			{
				return;
			}
			this.lblCol.Text = "径向数目";
			this.lblRow.Enabled = false;
			this.nudBZHS.Enabled = false;
			this.lblBJB.Enabled = false;
			this.nudBJB.Enabled = false;
		}

		private void SaveDlgData()
		{
			SaveFileDialog saveFileDialog = new SaveFileDialog();
			saveFileDialog.Filter = "*.ill|*.ill";
			string text = this.m_document.Title;
			text = text.Substring(0, text.IndexOf(".rvt"));
			saveFileDialog.FileName = text;
			if (saveFileDialog.ShowDialog() != DialogResult.OK)
			{
				return;
			}
			FileStream fileStream = new FileStream(saveFileDialog.FileName, FileMode.Create);
			StreamWriter streamWriter = new StreamWriter(fileStream);
			streamWriter.WriteLine(this.m_illCalData.arDGVData.Count.ToString());
			for (int i = 0; i < this.m_illCalData.arDGVData.Count; i++)
			{
				DGVRowData dgvrowData = this.m_illCalData.arDGVData.ElementAt(i);
				string value = dgvrowData.nIndex.ToString();
				streamWriter.WriteLine(value);
				value = dgvrowData.nFJBH.ToString();
				streamWriter.WriteLine(value);
				value = dgvrowData.sFJMC;
				streamWriter.WriteLine(value);
				value = dgvrowData.sFJLX;
				streamWriter.WriteLine(value);
				value = dgvrowData.dFJMJ.ToString();
				streamWriter.WriteLine(value);
				value = dgvrowData.dFJGD.ToString();
				streamWriter.WriteLine(value);
				value = dgvrowData.dGZMGD.ToString();
				streamWriter.WriteLine(value);
				value = dgvrowData.dAZGD.ToString();
				streamWriter.WriteLine(value);
				this.SaveFSXSData(streamWriter, dgvrowData.dDPFSXS);
				this.SaveFSXSData(streamWriter, dgvrowData.dSBFSXS);
				this.SaveFSXSData(streamWriter, dgvrowData.dXBFSXS);
				this.SaveFSXSData(streamWriter, dgvrowData.dDMFSXS);
				value = dgvrowData.dCMJ.ToString();
				streamWriter.WriteLine(value);
				value = dgvrowData.dCFSXS.ToString();
				streamWriter.WriteLine(value);
				value = dgvrowData.dPJZD.ToString();
				streamWriter.WriteLine(value);
				value = dgvrowData.dYQGLMD.ToString();
				streamWriter.WriteLine(value);
				this.SaveDjcsData(streamWriter, dgvrowData.djcsData);
				this.SaveGycsData(streamWriter, dgvrowData.gycsData);
				this.SaveLayoutData(streamWriter, dgvrowData.layoutData);
				this.SaveCalresultData(streamWriter, dgvrowData.calResultData);
				value = dgvrowData.sJZWLX;
				streamWriter.WriteLine(value);
				value = dgvrowData.sCSLX;
				streamWriter.WriteLine(value);
				value = dgvrowData.dPerimeter.ToString();
				streamWriter.WriteLine(value);
				if (dgvrowData.room != null)
				{
					value = dgvrowData.room.Id.IntegerValue.ToString();
					streamWriter.WriteLine(value);
				}
				else
				{
					streamWriter.WriteLine("-1");
				}
			}
			streamWriter.Flush();
			streamWriter.Close();
			fileStream.Close();
		}

		private void WriteXml()
		{
			SaveFileDialog saveFileDialog = new SaveFileDialog();
			saveFileDialog.Filter = "*.ill|*.ill";
			saveFileDialog.RestoreDirectory = true;
			string text = this.m_document.Title;
			if (text.Contains(".rvt"))
			{
				text = text.Substring(0, text.IndexOf(".rvt"));
			}
			saveFileDialog.FileName = text;
			if (saveFileDialog.ShowDialog() != DialogResult.OK)
			{
				return;
			}
			string fileName = saveFileDialog.FileName;
			if (this.m_illCalData.arDGVData.Count<DGVRowData>() > 0)
			{
				XmlDocument xmlDocument = new XmlDocument();
				XmlDeclaration newChild = xmlDocument.CreateXmlDeclaration("1.0", "UTF-8", null);
				xmlDocument.AppendChild(newChild);
				XmlElement newChild2 = xmlDocument.CreateElement("Boot");
				xmlDocument.AppendChild(newChild2);
				XmlNode xmlNode = xmlDocument.SelectSingleNode("Boot");
				XmlElement xmlElement = xmlDocument.CreateElement("DataItems");
				for (int i = 0; i < this.m_illCalData.arDGVData.Count; i++)
				{
					XmlElement xmlElement2 = xmlDocument.CreateElement("DataItem");
					DGVRowData dgvrowData = this.m_illCalData.arDGVData.ElementAt(i);
					xmlElement2.SetAttribute("Index", dgvrowData.nIndex.ToString());
					xmlElement2.SetAttribute("FJBH", dgvrowData.nFJBH.ToString());
					xmlElement2.SetAttribute("FJMC", dgvrowData.sFJMC);
					xmlElement2.SetAttribute("FJLX", dgvrowData.sFJLX);
					xmlElement2.SetAttribute("FJMJ", dgvrowData.dFJMJ.ToString());
					xmlElement2.SetAttribute("FJGD", dgvrowData.dFJGD.ToString());
					xmlElement2.SetAttribute("GZMGD", dgvrowData.dGZMGD.ToString());
					xmlElement2.SetAttribute("AZGD", dgvrowData.dAZGD.ToString());
					xmlElement2.SetAttribute("DPFSXS_Describe", dgvrowData.dDPFSXS.sDescribe);
					xmlElement2.SetAttribute("DPFSXS_Value", dgvrowData.dDPFSXS.dValue.ToString());
					xmlElement2.SetAttribute("SBFSXS_Describe", dgvrowData.dSBFSXS.sDescribe);
					xmlElement2.SetAttribute("SBFSXS_Value", dgvrowData.dSBFSXS.dValue.ToString());
					xmlElement2.SetAttribute("XBFSXS_Describe", dgvrowData.dXBFSXS.sDescribe);
					xmlElement2.SetAttribute("XBFSXS_Value", dgvrowData.dXBFSXS.dValue.ToString());
					xmlElement2.SetAttribute("DMFSXS_Describe", dgvrowData.dDMFSXS.sDescribe);
					xmlElement2.SetAttribute("DMFSXS_Value", dgvrowData.dDMFSXS.dValue.ToString());
					xmlElement2.SetAttribute("CMJ", dgvrowData.dCMJ.ToString());
					xmlElement2.SetAttribute("CFSXS", dgvrowData.dCFSXS.ToString());
					xmlElement2.SetAttribute("PJZD", dgvrowData.dPJZD.ToString());
					xmlElement2.SetAttribute("YQGLMD", dgvrowData.dYQGLMD.ToString());
					xmlElement2.SetAttribute("WallPerimeter", dgvrowData.dWallPerimeter.ToString());
					xmlElement2.SetAttribute("DJWHXS", dgvrowData.djcsData.dDJWHXS.ToString());
					xmlElement2.SetAttribute("DJLX", dgvrowData.djcsData.sDJLX);
					xmlElement2.SetAttribute("DJMC", dgvrowData.djcsData.sDJMC);
					xmlElement2.SetAttribute("DJXH", dgvrowData.djcsData.sDJXH);
					xmlElement2.SetAttribute("DJXL", dgvrowData.djcsData.dDJXL.ToString());
					xmlElement2.SetAttribute("LYXS", dgvrowData.djcsData.dLYXS.ToString());
					xmlElement2.SetAttribute("DJCS_AA", dgvrowData.djcsData.dAA.ToString());
					xmlElement2.SetAttribute("DJCS_BB", dgvrowData.djcsData.dBB.ToString());
					xmlElement2.SetAttribute("ZLQNum", dgvrowData.djcsData.nZLQNum.ToString());
					xmlElement2.SetAttribute("ZLQGL", dgvrowData.djcsData.dZLQGL.ToString());
					xmlElement2.SetAttribute("SCCJ", dgvrowData.gycsData.sSCCJ);
					xmlElement2.SetAttribute("GYLX", dgvrowData.gycsData.sGYLX);
					xmlElement2.SetAttribute("GYXH", dgvrowData.gycsData.sGYXH);
					xmlElement2.SetAttribute("GYMC", dgvrowData.gycsData.sGYMC);
					xmlElement2.SetAttribute("GYSL", dgvrowData.gycsData.nGYSL.ToString());
					xmlElement2.SetAttribute("GL", dgvrowData.gycsData.dGL.ToString());
					xmlElement2.SetAttribute("TGL", dgvrowData.gycsData.dTGL.ToString());
					xmlElement2.SetAttribute("DJNum", dgvrowData.layoutData.nDJNum.ToString());
					xmlElement2.SetAttribute("RowNum", dgvrowData.layoutData.nRowNum.ToString());
					xmlElement2.SetAttribute("ColNum", dgvrowData.layoutData.nColNum.ToString());
					xmlElement2.SetAttribute("Vector", dgvrowData.layoutData.nVector.ToString());
					xmlElement2.SetAttribute("BJB", dgvrowData.layoutData.dBJB.ToString());
					xmlElement2.SetAttribute("ZDZ", dgvrowData.calResultData.dZDZ.ToString());
					xmlElement2.SetAttribute("GLMD", dgvrowData.calResultData.dGLMD.ToString());
					xmlElement2.SetAttribute("HSGLMD", dgvrowData.calResultData.dHSGLMD.ToString());
					xmlElement2.SetAttribute("Calresult_AA", dgvrowData.calResultData.dAA.ToString());
					xmlElement2.SetAttribute("Calresult_BB", dgvrowData.calResultData.dBB.ToString());
					xmlElement2.SetAttribute("GLMDJH", dgvrowData.calResultData.sGLMDJH);
					xmlElement2.SetAttribute("ZDJYDJH", dgvrowData.calResultData.sZDJYDJH);
					xmlElement2.SetAttribute("JZWLX", dgvrowData.sJZWLX);
					xmlElement2.SetAttribute("CSLX", dgvrowData.sCSLX);
					xmlElement2.SetAttribute("Perimeter", dgvrowData.dPerimeter.ToString());
					if (dgvrowData.room != null)
					{
						xmlElement2.SetAttribute("Space_Id", dgvrowData.room.Id.IntegerValue.ToString());
					}
					else
					{
						xmlElement2.SetAttribute("Space_Id", dgvrowData.calResultData.sZDJYDJH);
					}
					xmlElement.AppendChild(xmlElement2);
				}
				xmlNode.AppendChild(xmlElement);
				xmlDocument.Save(fileName);
			}
		}

		private void SaveFSXSData(StreamWriter sWriter, FSXSData data)
		{
			string value = data.sDescribe;
			sWriter.WriteLine(value);
			value = data.dValue.ToString();
			sWriter.WriteLine(value);
		}

		private void SaveDjcsData(StreamWriter sWriter, DJCSData data)
		{
			string value = data.dDJWHXS.ToString();
			sWriter.WriteLine(value);
			value = data.sDJLX;
			sWriter.WriteLine(value);
			value = data.sDJMC;
			sWriter.WriteLine(value);
			value = data.sDJXH;
			sWriter.WriteLine(value);
			value = data.dDJXL.ToString();
			sWriter.WriteLine(value);
			value = data.dLYXS.ToString();
			sWriter.WriteLine(value);
			value = data.dAA.ToString();
			sWriter.WriteLine(value);
			value = data.dBB.ToString();
			sWriter.WriteLine(value);
			value = data.nZLQNum.ToString();
			sWriter.WriteLine(value);
			value = data.dZLQGL.ToString();
			sWriter.WriteLine(value);
		}

		private void SaveGycsData(StreamWriter sWriter, GYCSData data)
		{
			string value = data.sSCCJ;
			sWriter.WriteLine(value);
			value = data.sGYLX;
			sWriter.WriteLine(value);
			value = data.sGYXH;
			sWriter.WriteLine(value);
			value = data.sGYMC;
			sWriter.WriteLine(value);
			value = data.nGYSL.ToString();
			sWriter.WriteLine(value);
			value = data.dGL.ToString();
			sWriter.WriteLine(value);
			value = data.dTGL.ToString();
			sWriter.WriteLine(value);
		}

		private void SaveLayoutData(StreamWriter sWriter, LayoutData data)
		{
			string value = data.nDJNum.ToString();
			sWriter.WriteLine(value);
			value = data.nRowNum.ToString();
			sWriter.WriteLine(value);
			value = data.nColNum.ToString();
			sWriter.WriteLine(value);
			value = data.nVector.ToString();
			sWriter.WriteLine(value);
			value = data.dBJB.ToString();
			sWriter.WriteLine(value);
		}

		private void SaveCalresultData(StreamWriter sWriter, CalResultData data)
		{
			string value = data.dZDZ.ToString();
			sWriter.WriteLine(value);
			value = data.dGLMD.ToString();
			sWriter.WriteLine(value);
			value = data.dHSGLMD.ToString();
			sWriter.WriteLine(value);
			value = data.dAA.ToString();
			sWriter.WriteLine(value);
			value = data.dBB.ToString();
			sWriter.WriteLine(value);
			value = data.sGLMDJH;
			sWriter.WriteLine(value);
			value = data.sZDJYDJH;
			sWriter.WriteLine(value);
		}

		private bool LoadDlgData()
		{
			OpenFileDialog openFileDialog = new OpenFileDialog();
			openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
			openFileDialog.Filter = "*.ill|*.ill|所有文件(*.*)|*.*";
			if (openFileDialog.ShowDialog() != DialogResult.OK)
			{
				return false;
			}
			this.m_illCalData.arDGVData.Clear();
			FileStream fileStream = new FileStream(openFileDialog.FileName, FileMode.Open);
			StreamReader streamReader = new StreamReader(fileStream);
			streamReader.BaseStream.Seek(0L, SeekOrigin.Begin);
			string text = streamReader.ReadLine();
			int num = Convert.ToInt32(text);
			for (int i = 0; i < num; i++)
			{
				DGVRowData dgvrowData = new DGVRowData();
				text = streamReader.ReadLine();
				dgvrowData.nIndex = Convert.ToInt32(text);
				text = streamReader.ReadLine();
				dgvrowData.nFJBH = Convert.ToInt32(text);
				text = streamReader.ReadLine();
				dgvrowData.sFJMC = text;
				text = streamReader.ReadLine();
				dgvrowData.sFJLX = text;
				text = streamReader.ReadLine();
				dgvrowData.dFJMJ = Convert.ToDouble(text);
				text = streamReader.ReadLine();
				dgvrowData.dFJGD = Convert.ToDouble(text);
				text = streamReader.ReadLine();
				dgvrowData.dGZMGD = Convert.ToDouble(text);
				text = streamReader.ReadLine();
				dgvrowData.dAZGD = Convert.ToDouble(text);
				this.LoadFSXSData(streamReader, ref dgvrowData.dDPFSXS);
				this.LoadFSXSData(streamReader, ref dgvrowData.dSBFSXS);
				this.LoadFSXSData(streamReader, ref dgvrowData.dXBFSXS);
				this.LoadFSXSData(streamReader, ref dgvrowData.dDMFSXS);
				text = streamReader.ReadLine();
				dgvrowData.dCMJ = Convert.ToDouble(text);
				text = streamReader.ReadLine();
				dgvrowData.dCFSXS = Convert.ToDouble(text);
				text = streamReader.ReadLine();
				dgvrowData.dPJZD = Convert.ToDouble(text);
				text = streamReader.ReadLine();
				dgvrowData.dYQGLMD = Convert.ToDouble(text);
				this.LoadDjcsData(streamReader, ref dgvrowData.djcsData);
				this.LoadGycsData(streamReader, ref dgvrowData.gycsData);
				this.LoadLayoutData(streamReader, ref dgvrowData.layoutData);
				this.LoadCalresultData(streamReader, ref dgvrowData.calResultData);
				text = streamReader.ReadLine();
				dgvrowData.sJZWLX = text;
				text = streamReader.ReadLine();
				dgvrowData.sCSLX = text;
				text = streamReader.ReadLine();
				dgvrowData.dPerimeter = Convert.ToDouble(text);
				text = streamReader.ReadLine();
				int nId = Convert.ToInt32(text);
				if (this.FindRoomById(nId, ref dgvrowData.room))
				{
					this.m_illCalData.arDGVData.Add(dgvrowData);
				}
			}
			streamReader.Close();
			fileStream.Close();
			return true;
		}

		private bool ReadXML()
		{
			OpenFileDialog openFileDialog = new OpenFileDialog();
			openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
			openFileDialog.Filter = "*.ill|*.ill|所有文件(*.*)|*.*";
			if (openFileDialog.ShowDialog() != DialogResult.OK)
			{
				return false;
			}
			this.m_illCalData.arDGVData.Clear();
			string fileName = openFileDialog.FileName;
			XmlDocument xmlDocument = new XmlDocument();
			xmlDocument.Load(fileName);
			foreach (object obj in xmlDocument.DocumentElement.ChildNodes)
			{
				XmlNode xmlNode = (XmlNode)obj;
				if (xmlNode.Name == "DataItems")
				{
					foreach (object obj2 in xmlNode.ChildNodes)
					{
						XmlNode xmlNode2 = (XmlNode)obj2;
						if (xmlNode2.Name == "DataItem")
						{
							DGVRowData dgvrowData = new DGVRowData();
							for (int i = 0; i < xmlNode2.Attributes.Count; i++)
							{
								string localName = xmlNode2.Attributes[i].LocalName;
								uint num = 0;//<PrivateImplementationDetails>.ComputeStringHash(localName);
								if (num <= 2771777419u)
								{
									if (num <= 1515568737u)
									{
										if (num <= 737091699u)
										{
											if (num <= 561305196u)
											{
												if (num != 119127374u)
												{
													if (num != 293612603u)
													{
														if (num == 561305196u)
														{
															if (localName == "ZDJYDJH")
															{
																dgvrowData.calResultData.sZDJYDJH = xmlNode2.Attributes[i].Value.ToString();
															}
														}
													}
													else if (localName == "LYXS")
													{
														dgvrowData.djcsData.dLYXS = Convert.ToDouble(xmlNode2.Attributes[i].Value);
													}
												}
												else if (localName == "HSGLMD")
												{
													dgvrowData.calResultData.dHSGLMD = Convert.ToDouble(xmlNode2.Attributes[i].Value);
												}
											}
											else if (num != 566904035u)
											{
												if (num != 574794939u)
												{
													if (num == 737091699u)
													{
														if (localName == "Space_Id")
														{
															int nId = Convert.ToInt32(xmlNode2.Attributes[i].Value);
															if (this.FindRoomById(nId, ref dgvrowData.room))
															{
																this.m_illCalData.arDGVData.Add(dgvrowData);
															}
														}
													}
												}
												else if (localName == "Calresult_BB")
												{
													dgvrowData.calResultData.dBB = Convert.ToDouble(xmlNode2.Attributes[i].Value);
												}
											}
											else if (localName == "ZDZ")
											{
												dgvrowData.calResultData.dZDZ = Convert.ToDouble(xmlNode2.Attributes[i].Value);
											}
										}
										else if (num <= 959662383u)
										{
											if (num != 818630553u)
											{
												if (num != 876204089u)
												{
													if (num == 959662383u)
													{
														if (localName == "CSLX")
														{
															dgvrowData.sCSLX = xmlNode2.Attributes[i].Value.ToString();
														}
													}
												}
												else if (localName == "DPFSXS_Describe")
												{
													dgvrowData.dDPFSXS.sDescribe = xmlNode2.Attributes[i].Value;
												}
											}
											else if (localName == "DJNum")
											{
												dgvrowData.layoutData.nDJNum = Convert.ToInt32(xmlNode2.Attributes[i].Value);
											}
										}
										else if (num <= 1296160366u)
										{
											if (num != 1235994529u)
											{
												if (num == 1296160366u)
												{
													if (localName == "ZLQNum")
													{
														dgvrowData.djcsData.nZLQNum = Convert.ToInt32(xmlNode2.Attributes[i].Value);
													}
												}
											}
											else if (localName == "DPFSXS_Value")
											{
												dgvrowData.dDPFSXS.dValue = Convert.ToDouble(xmlNode2.Attributes[i].Value);
											}
										}
										else if (num != 1472007366u)
										{
											if (num == 1515568737u)
											{
												if (localName == "AZGD")
												{
													dgvrowData.dAZGD = Convert.ToDouble(xmlNode2.Attributes[i].Value);
												}
											}
										}
										else if (localName == "SBFSXS_Describe")
										{
											dgvrowData.dSBFSXS.sDescribe = xmlNode2.Attributes[i].Value;
										}
									}
									else if (num <= 2188810009u)
									{
										if (num <= 1874963938u)
										{
											if (num != 1657862494u)
											{
												if (num != 1750236609u)
												{
													if (num == 1874963938u)
													{
														if (localName == "GYSL")
														{
															dgvrowData.gycsData.nGYSL = Convert.ToInt32(xmlNode2.Attributes[i].Value);
														}
													}
												}
												else if (localName == "PJZD")
												{
													dgvrowData.dPJZD = Convert.ToDouble(xmlNode2.Attributes[i].Value);
												}
											}
											else if (localName == "GL")
											{
												dgvrowData.gycsData.dGL = Convert.ToDouble(xmlNode2.Attributes[i].Value);
											}
										}
										else if (num <= 2003620005u)
										{
											if (num != 1982749348u)
											{
												if (num == 2003620005u)
												{
													if (localName == "CMJ")
													{
														dgvrowData.dCMJ = Convert.ToDouble(xmlNode2.Attributes[i].Value);
													}
												}
											}
											else if (localName == "CFSXS")
											{
												dgvrowData.dCFSXS = Convert.ToDouble(xmlNode2.Attributes[i].Value);
											}
										}
										else if (num != 2135627808u)
										{
											if (num == 2188810009u)
											{
												if (localName == "GYMC")
												{
													dgvrowData.gycsData.sGYMC = xmlNode2.Attributes[i].Value;
												}
											}
										}
										else if (localName == "DJCS_AA")
										{
											dgvrowData.djcsData.dAA = Convert.ToDouble(xmlNode2.Attributes[i].Value);
										}
									}
									else if (num <= 2510983269u)
									{
										if (num != 2283296312u)
										{
											if (num != 2420302878u)
											{
												if (num == 2510983269u)
												{
													if (localName == "GYXH")
													{
														dgvrowData.gycsData.sGYXH = xmlNode2.Attributes[i].Value;
													}
												}
											}
											else if (localName == "DJCS_BB")
											{
												dgvrowData.djcsData.dBB = Convert.ToDouble(xmlNode2.Attributes[i].Value);
											}
										}
										else if (localName == "SBFSXS_Value")
										{
											dgvrowData.dSBFSXS.dValue = Convert.ToDouble(xmlNode2.Attributes[i].Value);
										}
									}
									else if (num <= 2641952817u)
									{
										if (num != 2543018757u)
										{
											if (num == 2641952817u)
											{
												if (localName == "GYLX")
												{
													dgvrowData.gycsData.sGYLX = xmlNode2.Attributes[i].Value;
												}
											}
										}
										else if (localName == "DJWHXS")
										{
											dgvrowData.djcsData.dDJWHXS = Convert.ToDouble(xmlNode2.Attributes[i].Value);
										}
									}
									else if (num != 2731542404u)
									{
										if (num == 2771777419u)
										{
											if (localName == "XBFSXS_Value")
											{
												dgvrowData.dXBFSXS.dValue = Convert.ToDouble(xmlNode2.Attributes[i].Value);
											}
										}
									}
									else if (localName == "WallPerimeter")
									{
										dgvrowData.dWallPerimeter = Convert.ToDouble(xmlNode2.Attributes[i].Value);
									}
								}
								else if (num <= 3509955846u)
								{
									if (num <= 3028028147u)
									{
										if (num <= 2848909117u)
										{
											if (num != 2794379351u)
											{
												if (num != 2843690242u)
												{
													if (num == 2848909117u)
													{
														if (localName == "GLMDJH")
														{
															dgvrowData.calResultData.sGLMDJH = xmlNode2.Attributes[i].Value.ToString();
														}
													}
												}
												else if (localName == "JZWLX")
												{
													dgvrowData.sJZWLX = xmlNode2.Attributes[i].Value.ToString();
												}
											}
											else if (localName == "GLMD")
											{
												dgvrowData.calResultData.dGLMD = Convert.ToDouble(xmlNode2.Attributes[i].Value);
											}
										}
										else if (num != 2932321867u)
										{
											if (num != 2985805955u)
											{
												if (num == 3028028147u)
												{
													if (localName == "DJMC")
													{
														dgvrowData.djcsData.sDJMC = xmlNode2.Attributes[i].Value;
													}
												}
											}
											else if (localName == "XBFSXS_Describe")
											{
												dgvrowData.dXBFSXS.sDescribe = xmlNode2.Attributes[i].Value;
											}
										}
										else if (localName == "Index")
										{
											dgvrowData.nIndex = Convert.ToInt32(xmlNode2.Attributes[i].Value);
										}
									}
									else if (num <= 3410359645u)
									{
										if (num != 3159403810u)
										{
											if (num != 3160483508u)
											{
												if (num == 3410359645u)
												{
													if (localName == "Calresult_AA")
													{
														dgvrowData.calResultData.dAA = Convert.ToDouble(xmlNode2.Attributes[i].Value);
													}
												}
											}
											else if (localName == "Perimeter")
											{
												dgvrowData.dPerimeter = Convert.ToDouble(xmlNode2.Attributes[i].Value);
											}
										}
										else if (localName == "Vector")
										{
											dgvrowData.layoutData.nVector = Convert.ToInt32(xmlNode2.Attributes[i].Value);
										}
									}
									else if (num <= 3448278093u)
									{
										if (num != 3434168473u)
										{
											if (num == 3448278093u)
											{
												if (localName == "BJB")
												{
													dgvrowData.layoutData.dBJB = Convert.ToDouble(xmlNode2.Attributes[i].Value);
												}
											}
										}
										else if (localName == "RowNum")
										{
											dgvrowData.layoutData.nRowNum = Convert.ToInt32(xmlNode2.Attributes[i].Value);
										}
									}
									else if (num != 3464095012u)
									{
										if (num == 3509955846u)
										{
											if (localName == "DMFSXS_Value")
											{
												dgvrowData.dDMFSXS.dValue = Convert.ToDouble(xmlNode2.Attributes[i].Value);
											}
										}
									}
									else if (localName == "DMFSXS_Describe")
									{
										dgvrowData.dDMFSXS.sDescribe = xmlNode2.Attributes[i].Value;
									}
								}
								else if (num <= 3746361455u)
								{
									if (num <= 3635937296u)
									{
										if (num != 3548281431u)
										{
											if (num != 3592853173u)
											{
												if (num == 3635937296u)
												{
													if (localName == "GZMGD")
													{
														dgvrowData.dGZMGD = Convert.ToDouble(xmlNode2.Attributes[i].Value);
													}
												}
											}
											else if (localName == "YQGLMD")
											{
												dgvrowData.dYQGLMD = Convert.ToDouble(xmlNode2.Attributes[i].Value);
											}
										}
										else if (localName == "DJLX")
										{
											dgvrowData.djcsData.sDJLX = xmlNode2.Attributes[i].Value;
										}
									}
									else if (num <= 3708085042u)
									{
										if (num != 3679250979u)
										{
											if (num == 3708085042u)
											{
												if (localName == "FJMJ")
												{
													dgvrowData.dFJMJ = Convert.ToDouble(xmlNode2.Attributes[i].Value);
												}
											}
										}
										else if (localName == "DJXH")
										{
											dgvrowData.djcsData.sDJXH = xmlNode2.Attributes[i].Value;
										}
									}
									else if (num != 3711431936u)
									{
										if (num == 3746361455u)
										{
											if (localName == "DJXL")
											{
												dgvrowData.djcsData.dDJXL = Convert.ToDouble(xmlNode2.Attributes[i].Value);
											}
										}
									}
									else if (localName == "TGL")
									{
										dgvrowData.gycsData.dTGL = Convert.ToDouble(xmlNode2.Attributes[i].Value);
									}
								}
								else if (num <= 3810324874u)
								{
									if (num != 3780164319u)
									{
										if (num != 3788049069u)
										{
											if (num == 3810324874u)
											{
												if (localName == "FJGD")
												{
													dgvrowData.dFJGD = Convert.ToDouble(xmlNode2.Attributes[i].Value);
												}
											}
										}
										else if (localName == "ZLQGL")
										{
											dgvrowData.djcsData.dZLQGL = Convert.ToDouble(xmlNode2.Attributes[i].Value);
										}
									}
									else if (localName == "ColNum")
									{
										dgvrowData.layoutData.nColNum = Convert.ToInt32(xmlNode2.Attributes[i].Value);
									}
								}
								else if (num <= 3872609902u)
								{
									if (num != 3859083613u)
									{
										if (num == 3872609902u)
										{
											if (localName == "SCCJ")
											{
												dgvrowData.gycsData.sSCCJ = xmlNode2.Attributes[i].Value.ToString();
											}
										}
									}
									else if (localName == "FJMC")
									{
										dgvrowData.sFJMC = xmlNode2.Attributes[i].Value;
									}
								}
								else if (num != 4043784517u)
								{
									if (num == 4111880731u)
									{
										if (localName == "FJBH")
										{
											dgvrowData.nFJBH = Convert.ToInt32(xmlNode2.Attributes[i].Value);
										}
									}
								}
								else if (localName == "FJLX")
								{
									dgvrowData.sFJLX = xmlNode2.Attributes[i].Value;
								}
							}
						}
					}
				}
			}
			return true;
		}

		private bool LoadFSXSData(StreamReader sReader, ref FSXSData data)
		{
			string text = sReader.ReadLine();
			data.sDescribe = text;
			text = sReader.ReadLine();
			data.dValue = Convert.ToDouble(text);
			return true;
		}

		private bool LoadDjcsData(StreamReader sReader, ref DJCSData data)
		{
			string text = sReader.ReadLine();
			data.dDJWHXS = Convert.ToDouble(text);
			text = sReader.ReadLine();
			data.sDJLX = text;
			text = sReader.ReadLine();
			data.sDJMC = text;
			text = sReader.ReadLine();
			data.sDJXH = text;
			text = sReader.ReadLine();
			data.dDJXL = Convert.ToDouble(text);
			text = sReader.ReadLine();
			data.dLYXS = Convert.ToDouble(text);
			text = sReader.ReadLine();
			data.dAA = Convert.ToDouble(text);
			text = sReader.ReadLine();
			data.dBB = Convert.ToDouble(text);
			text = sReader.ReadLine();
			data.nZLQNum = Convert.ToInt32(text);
			text = sReader.ReadLine();
			data.dZLQGL = Convert.ToDouble(text);
			return true;
		}

		private bool LoadGycsData(StreamReader sReader, ref GYCSData data)
		{
			string text = sReader.ReadLine();
			data.sSCCJ = text;
			text = sReader.ReadLine();
			data.sGYLX = text;
			text = sReader.ReadLine();
			data.sGYXH = text;
			text = sReader.ReadLine();
			data.sGYMC = text;
			text = sReader.ReadLine();
			data.nGYSL = Convert.ToInt32(text);
			text = sReader.ReadLine();
			data.dGL = Convert.ToDouble(text);
			text = sReader.ReadLine();
			data.dTGL = Convert.ToDouble(text);
			return true;
		}

		private bool LoadLayoutData(StreamReader sReader, ref LayoutData data)
		{
			string value = sReader.ReadLine();
			data.nDJNum = Convert.ToInt32(value);
			value = sReader.ReadLine();
			data.nRowNum = Convert.ToInt32(value);
			value = sReader.ReadLine();
			data.nColNum = Convert.ToInt32(value);
			value = sReader.ReadLine();
			data.nVector = Convert.ToInt32(value);
			value = sReader.ReadLine();
			data.dBJB = Convert.ToDouble(value);
			return true;
		}

		private bool LoadCalresultData(StreamReader sReader, ref CalResultData data)
		{
			string text = sReader.ReadLine();
			data.dZDZ = Convert.ToDouble(text);
			text = sReader.ReadLine();
			data.dGLMD = Convert.ToDouble(text);
			text = sReader.ReadLine();
			data.dHSGLMD = Convert.ToDouble(text);
			text = sReader.ReadLine();
			data.dAA = Convert.ToDouble(text);
			text = sReader.ReadLine();
			data.dBB = Convert.ToDouble(text);
			text = sReader.ReadLine();
			data.sGLMDJH = text;
			text = sReader.ReadLine();
			data.sZDJYDJH = text;
			return true;
		}

		private bool FindRoomById(int nId, ref Space room)
		{
			ElementId elementId = new ElementId(nId);
			room = (this.m_document.GetElementById(elementId) as Space);
			return room != null;
		}

		private void CalUseFactor()
		{
			double num = new FindUseFactor(this.m_illCalData.activeDGVRowData).GetUseFactor();
			num += 0.005;
			this.tbLYXS.Text = num.ToString("0.00");
			this.m_illCalData.activeDGVRowData.djcsData.dLYXS = num;
		}

		private void SetBindingSource()
		{
			this.bindingSourceDGVRowData.DataSource = typeof(DGVRowData);
			this.dgvRoomData.DataSource = this.bindingSourceDGVRowData;
			this.bindingSourceDGVRowData.DataSource = this.m_illCalData.arDGVData;
		}

		private bool IsDJCSDataCorrect()
		{
			return true;
		}

		private bool IsGYCSDataCorrect()
		{
			return true;
		}

		private bool IsUseFactorCalDataCorrect()
		{
			if (this.m_illCalData.activeDGVRowData.gycsData.sGYXH == null)
			{
				MessageBox.Show("光源型号参数不能为空！");
				return false;
			}
			return true;
		}

		private bool IsCalDataCorrect()
		{
			if (this.m_illCalData.activeDGVRowData.djcsData.dLYXS <= 0.0)
			{
				MessageBox.Show("利用系数不正确，请检查！");
				this.tbLYXS.Focus();
				return false;
			}
			if (this.m_illCalData.activeDGVRowData.djcsData.dLYXS < 0.05)
			{
				MessageBox.Show("未能通过查表获取正确的利用系数，请手动检查或输入！");
				this.tbLYXS.Focus();
				return false;
			}
			if (this.m_illCalData.activeDGVRowData.dPJZD <= 0.0)
			{
				MessageBox.Show("房间平均照度不正确，请检查！");
				return false;
			}
			return true;
		}

		private void CompressKeyPtsByRoomType()
		{
			switch (CalUtility.GetRoomTypeByString(this.m_illCalData.activeDGVRowData.sFJLX))
			{
			case ROOMTYPE.eRect:
				GeoUtil.CompressPtsByDirect(this.m_application, this.m_illCalData.activeDGVRowData.arPtRoom);
				GeoUtil.GrahamScan(this.m_illCalData.activeDGVRowData.arPtRoom);
				break;
			case ROOMTYPE.ePoly:
			case ROOMTYPE.eArc:
			case ROOMTYPE.eBow:
			case ROOMTYPE.eSector:
				break;
			default:
				return;
			}
		}

		private void GetCalResultByLampCount()
		{
			DGVRowData activeDGVRowData = this.m_illCalData.activeDGVRowData;
			DJCSData djcsData = activeDGVRowData.djcsData;
			GYCSData gycsData = activeDGVRowData.gycsData;
			LayoutData layoutData = activeDGVRowData.layoutData;
			CalResultData calResultData = activeDGVRowData.calResultData;
			double num = (double)layoutData.nDJNum * gycsData.dTGL * (double)gycsData.nGYSL * djcsData.dLYXS * djcsData.dDJWHXS / this.m_illCalData.activeDGVRowData.dFJMJ;
			calResultData.dZDZ = num;
			int nZLQNum = djcsData.nZLQNum;
			double dZLQGL = djcsData.dZLQGL;
			double num2 = (double)layoutData.nDJNum * (dZLQGL * (double)nZLQNum + gycsData.dGL * (double)gycsData.nGYSL) / activeDGVRowData.dFJMJ;
			calResultData.dGLMD = num2;
			calResultData.dHSGLMD = activeDGVRowData.dPJZD * num2 / num;
			if (activeDGVRowData.dYQGLMD < 0.0001)
			{
				calResultData.sGLMDJH = "满足";
			}
			else if (calResultData.dHSGLMD < activeDGVRowData.dYQGLMD && calResultData.dHSGLMD > 0.0001)
			{
				calResultData.sGLMDJH = "满足";
			}
			else
			{
				calResultData.sGLMDJH = "不满足";
			}
			if (calResultData.dAA > 0.01 && calResultData.dAA < djcsData.dAA && calResultData.dBB > 0.01 && calResultData.dBB < djcsData.dBB)
			{
				calResultData.sZDJYDJH = "满足";
			}
			else
			{
				calResultData.sZDJYDJH = "不满足";
			}
			this.tbZDZ.Text = calResultData.dZDZ.ToString("0.00");
			this.tbGLMD.Text = calResultData.dGLMD.ToString("0.00");
			this.tbHSGLMD.Text = calResultData.dHSGLMD.ToString("0.00");
			this.tbGLMDJH.Text = calResultData.sGLMDJH;
			this.tbJSAA.Text = calResultData.dAA.ToString("0.00");
			this.tbJSBB.Text = calResultData.dBB.ToString("0.00");
			this.tbZDJH.Text = calResultData.sZDJYDJH;
		}

		private void ModifyLightVal()
		{
			DGVRowData activeDGVRowData = this.m_illCalData.activeDGVRowData;
			if (activeDGVRowData.sFJLX == "矩形" || activeDGVRowData.sFJLX == "多边形")
			{
				activeDGVRowData.layoutData.nDJNum = activeDGVRowData.layoutData.nColNum * activeDGVRowData.layoutData.nRowNum;
				this.tbJSDJTS.Text = activeDGVRowData.layoutData.nDJNum.ToString();
			}
		}

		private void GetAABBValAndSetVal()
		{
			DGVRowData activeDGVRowData = this.m_illCalData.activeDGVRowData;
			if (activeDGVRowData.sFJLX == "矩形")
			{
				this.GetRecAABBValAndSetVal();
			}
			if (activeDGVRowData.sFJLX == "多边形")
			{
				this.GetPolyAABBValAndSetVal();
			}
		}

		private void GetRecAABBValAndSetVal()
		{
			DGVRowData activeDGVRowData = this.m_illCalData.activeDGVRowData;
			if (activeDGVRowData.arPtRoom.Count < 4)
			{
				return;
			}
			if (activeDGVRowData.layoutData.nColNum > 0 && activeDGVRowData.layoutData.nRowNum > 0 && activeDGVRowData.dAZGD > 0.0)
			{
				double num = 2.0 * activeDGVRowData.layoutData.dBJB + (double)activeDGVRowData.layoutData.nRowNum - 1.0;
				if (num > 0.0)
				{
					activeDGVRowData.calResultData.dAA = Assist.AssistFunc.feetToMM(activeDGVRowData.arPtRoom[0].DistanceTo(activeDGVRowData.arPtRoom[3])) / num / 1000.0 / activeDGVRowData.dAZGD;
				}
				num = 2.0 * activeDGVRowData.layoutData.dBJB + (double)activeDGVRowData.layoutData.nColNum - 1.0;
				if (num > 0.0)
				{
					activeDGVRowData.calResultData.dBB = Assist.AssistFunc.feetToMM(activeDGVRowData.arPtRoom[0].DistanceTo(activeDGVRowData.arPtRoom[1])) / num / 1000.0 / activeDGVRowData.dAZGD;
				}
				this.tbJSAA.Text = activeDGVRowData.calResultData.dAA.ToString("0.00");
				this.tbJSBB.Text = activeDGVRowData.calResultData.dBB.ToString("0.00");
			}
		}

		private void GetPolyAABBValAndSetVal()
		{
			DGVRowData activeDGVRowData = this.m_illCalData.activeDGVRowData;
			XYZ xyz = new XYZ();
			XYZ xyz2 = new XYZ();
			GeoUtil.GetPolyBoundPts(activeDGVRowData.arPtRoom, ref xyz, ref xyz2);
			XYZ xyz3 = new XYZ(xyz.X, xyz2.Y, 0.0);
			if (activeDGVRowData.dAZGD > 0.0)
			{
				double num = 2.0 * activeDGVRowData.layoutData.dBJB + (double)activeDGVRowData.layoutData.nRowNum - 1.0;
				if (num > 0.0)
				{
					activeDGVRowData.calResultData.dAA = Assist.AssistFunc.feetToMM(xyz3.DistanceTo(xyz2)) / num / 1000.0 / activeDGVRowData.dAZGD;
				}
				num = 2.0 * activeDGVRowData.layoutData.dBJB + (double)activeDGVRowData.layoutData.nColNum - 1.0;
				if (num > 0.0)
				{
					activeDGVRowData.calResultData.dBB = Assist.AssistFunc.feetToMM(xyz3.DistanceTo(xyz)) / num / 1000.0 / activeDGVRowData.dAZGD;
				}
			}
			this.tbJSAA.Text = activeDGVRowData.calResultData.dAA.ToString("0.00");
			this.tbJSBB.Text = activeDGVRowData.calResultData.dBB.ToString("0.00");
		}

		public void RefreshDGVByCancleAddRoom()
		{
			this.RefreshDataGridView();
			if (this.m_illCalData.arDGVData.Count > 0)
			{
				int num = this.dgvRoomData.Rows.Count - 1;
				this.dgvRoomData.Rows[num].Selected = true;
				this.dgvRoomData.CurrentCell = this.dgvRoomData.Rows[num].Cells[0];
				this.m_illCalData.activeDGVRowData = this.m_illCalData.arDGVData.Last<DGVRowData>();
			}
		}

		private void RefreshDataGridView()
		{
			this.SetBindingSource();
			for (int i = 0; i < this.m_illCalData.arDGVData.Count; i++)
			{
				DGVRowData dgvrowData = this.m_illCalData.arDGVData.ElementAt(i);
				this.dgvRoomData.Rows[i].Cells[0].Value = dgvrowData.nIndex;
				this.dgvRoomData.Rows[i].Cells[1].Value = dgvrowData.nFJBH;
				this.dgvRoomData.Rows[i].Cells[2].Value = dgvrowData.sFJMC;
				this.dgvRoomData.Rows[i].Cells[3].Value = dgvrowData.sFJLX;
				this.dgvRoomData.Rows[i].Cells[4].Value = dgvrowData.dFJMJ;
				this.dgvRoomData.Rows[i].Cells[5].Value = dgvrowData.dFJGD;
				this.dgvRoomData.Rows[i].Cells[6].Value = dgvrowData.dGZMGD;
				this.dgvRoomData.Rows[i].Cells[7].Value = dgvrowData.dAZGD;
				this.dgvRoomData.Rows[i].Cells[8].Value = dgvrowData.dDPFSXS.dValue.ToString();
				this.dgvRoomData.Rows[i].Cells[9].Value = dgvrowData.dSBFSXS.dValue.ToString();
				this.dgvRoomData.Rows[i].Cells[10].Value = dgvrowData.dXBFSXS.dValue.ToString();
				this.dgvRoomData.Rows[i].Cells[11].Value = dgvrowData.dDMFSXS.dValue.ToString();
				this.dgvRoomData.Rows[i].Cells[12].Value = dgvrowData.dCMJ;
				this.dgvRoomData.Rows[i].Cells[13].Value = dgvrowData.dCFSXS;
				this.dgvRoomData.Rows[i].Cells[14].Value = dgvrowData.dPJZD;
				this.dgvRoomData.Rows[i].Cells[15].Value = dgvrowData.dYQGLMD;
			}
		}

		private void ResetcmbDropDownWidth(DataGridViewComboBoxColumn dgvCmbCol)
		{
			Graphics graphics = null;
			try
			{
				graphics = base.CreateGraphics();
				int num = dgvCmbCol.DropDownWidth;
				Font font = this.dgvRoomData.Font;
				int num2 = (dgvCmbCol.Items.Count > dgvCmbCol.MaxDropDownItems) ? SystemInformation.VerticalScrollBarWidth : 0;
				int num3 = 0;
				foreach (object obj in dgvCmbCol.Items)
				{
					if (obj != null)
					{
						num3 = (int)graphics.MeasureString(obj.ToString().Trim(), font).Width + num2;
						if (num < num3)
						{
							num = num3;
						}
					}
				}
				dgvCmbCol.DropDownWidth = num3;
			}
			catch
			{
			}
			finally
			{
				if (graphics != null)
				{
					graphics.Dispose();
				}
			}
		}

		private void dgvRoomData_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
		{
			int columnIndex = this.dgvRoomData.CurrentCell.ColumnIndex;
			if (columnIndex != 2 && columnIndex != 3)
			{
				this.EditingControl = (DataGridViewTextBoxEditingControl)e.Control;
				this.EditingControl.KeyPress += this.EditingControl_KeyPress;
				this.EditingControl.TextChanged += this.EditingControl_TextChanged;
			}
			if (this.dgvRoomData.CurrentCell.GetType().Name == "DataGridViewComboBoxCell")
			{
                System.Windows.Forms.ComboBox comboBox = (System.Windows.Forms.ComboBox)e.Control;
				comboBox.SelectedIndexChanged -= this.ComboBox_SelectedIndexChanged;
				comboBox.SelectedIndexChanged += this.ComboBox_SelectedIndexChanged;
			}
		}

		private void dgvRoomData_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
		{
			int columnIndex = e.ColumnIndex;
			if (columnIndex != 2 && columnIndex != 3)
			{
                System.Windows.Forms.TextBox textBox = new System.Windows.Forms.TextBox();
				if (this.dgvRoomData.Rows[e.RowIndex].Cells[e.ColumnIndex].Value == null)
				{
					textBox.Text = "";
				}
				else
				{
					textBox.Text = this.dgvRoomData.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
				}
				this.NotePastText(textBox, ref this.PastText);
			}
		}

		private void EditingControl_TextChanged(object sender, EventArgs e)
		{
			if (this.IsNumeric(this.EditingControl.Text, true, true))
			{
				this.NotePastText(this.EditingControl, ref this.PastText);
				return;
			}
			this.RestoreText(this.EditingControl, this.PastText);
		}

		private void EditingControl_KeyPress(object sender, KeyPressEventArgs e)
		{
			this.CheckKeyIn(e, true);
		}

		private bool IsNumeric(string NumStr, bool MayEmpty, bool ContainDot)
		{
			if ((NumStr ?? "") == "")
			{
				return MayEmpty;
			}
			if (ContainDot)
			{
				int num = NumStr.IndexOf('.');
				if (num >= 0)
				{
					num = NumStr.IndexOf('.', num + 1);
					if (num >= 0)
					{
						return false;
					}
				}
			}
			else if (NumStr.IndexOf('.') >= 0)
			{
				return false;
			}
			char[] array = NumStr.ToCharArray();
			for (int i = 0; i <= array.GetUpperBound(0); i++)
			{
				if (!char.IsDigit(array[i]))
				{
					if (array[i] != '.')
					{
						return false;
					}
					if (!ContainDot)
					{
						return false;
					}
				}
			}
			return !ContainDot || NumStr.Replace('.', '\0').Length > 0;
		}

		private void CheckKeyIn(KeyPressEventArgs Key, bool AllowDot)
		{
			if (char.IsControl(Key.KeyChar))
			{
				return;
			}
			if (char.IsDigit(Key.KeyChar))
			{
				return;
			}
			if (Key.KeyChar == '.')
			{
				if (!AllowDot)
				{
					Key.KeyChar = '\0';
				}
				return;
			}
			Key.KeyChar = '\0';
		}

		private void NotePastText(DataGridViewTextBoxEditingControl txtFrom, ref DlgIllCalMain.struPastText NoteTo)
		{
			if (txtFrom.Text == "" || txtFrom.Text == null)
			{
				txtFrom.Text = "0";
			}
			NoteTo.Text = txtFrom.Text;
			NoteTo.SelStart = txtFrom.SelectionStart;
			NoteTo.SelLength = txtFrom.SelectionLength;
		}

        private void NotePastText(System.Windows.Forms.TextBox txtFrom, ref DlgIllCalMain.struPastText NoteTo)
		{
			if (txtFrom.Text == "" || txtFrom.Text == null)
			{
				txtFrom.Text = "0";
			}
			NoteTo.Text = txtFrom.Text;
			NoteTo.SelStart = txtFrom.SelectionStart;
			NoteTo.SelLength = txtFrom.SelectionLength;
		}

		private void RestoreText(DataGridViewTextBoxEditingControl txtRestoreTo, DlgIllCalMain.struPastText TextFrom)
		{
			txtRestoreTo.Text = TextFrom.Text;
			txtRestoreTo.SelectionStart = TextFrom.SelStart;
			txtRestoreTo.SelectionLength = TextFrom.SelLength;
		}

		private void DlgIllCalMain_Load(object sender, EventArgs e)
		{
			//base.Icon = Resource.YArchitechIcon;
		}

		private void cmbDPFSXS_SelectionChangeCommitted(object sender, EventArgs e)
		{
			this.SetFSXSValue(sender);
		}

		private void cmbQSBFSXS_SelectionChangeCommitted(object sender, EventArgs e)
		{
			this.SetFSXSValue(sender);
		}

		private void cmbQXBFSXS_SelectionChangeCommitted(object sender, EventArgs e)
		{
			this.SetFSXSValue(sender);
		}

		private void cmbDMFSXS_SelectionChangeCommitted(object sender, EventArgs e)
		{
			this.SetFSXSValue(sender);
		}

		private void SetFSXSValue(object sender)
		{
            YArchitech.Electric.Controls.YJKComboBox hycomboBox = sender as YArchitech.Electric.Controls.YJKComboBox;
			FSXSData fsxsdata = hycomboBox.SelectedItem as FSXSData;
			this.dgvRoomData.CurrentCell.Value = fsxsdata.dValue.ToString();
			switch (this.dgvRoomData.CurrentCell.ColumnIndex)
			{
			case 8:
				this.m_illCalData.arDGVData.ElementAt(this.dgvRoomData.CurrentRow.Index).dDPFSXS = fsxsdata;
				break;
			case 9:
				this.m_illCalData.arDGVData.ElementAt(this.dgvRoomData.CurrentRow.Index).dSBFSXS = fsxsdata;
				break;
			case 10:
				this.m_illCalData.arDGVData.ElementAt(this.dgvRoomData.CurrentRow.Index).dXBFSXS = fsxsdata;
				break;
			case 11:
				this.m_illCalData.arDGVData.ElementAt(this.dgvRoomData.CurrentRow.Index).dDMFSXS = fsxsdata;
				break;
			}
			hycomboBox.Visible = false;
		}

		private void cmbDPFSXS_TextChanged(object sender, EventArgs e)
		{
			this.ExecuteTextChanged(sender);
		}

		private void cmbQSBFSXS_TextChanged(object sender, EventArgs e)
		{
			this.ExecuteTextChanged(sender);
		}

		private void cmbQXBFSXS_TextChanged(object sender, EventArgs e)
		{
			this.ExecuteTextChanged(sender);
		}

		private void cmbDMFSXS_TextChanged(object sender, EventArgs e)
		{
			this.ExecuteTextChanged(sender);
		}

		private void ExecuteTextChanged(object sender)
		{
            string text = (sender as YArchitech.Electric.Controls.YJKComboBox).Text;
			string[] array = new string[0];
			array = text.Split(new char[]
			{
				':'
			});
			if (array.Length != 0)
			{
				string numStr = array.Last<string>();
				if (this.IsNumeric(numStr, false, false))
				{
					this.dgvRoomData.CurrentCell.Value = array.Last<string>();
				}
			}
		}

		public SqliteElectricDatabase dbIllAndPower;

		public FamilyLibDatabase electricDB;

		public IllCalData m_illCalData;

		public int m_nDlgRstType;

		public int m_nSelRoomType;

		private UIApplication m_application;

		private Document m_document;

		public double m_elevation;

		private DataGridViewTextBoxEditingControl EditingControl = new DataGridViewTextBoxEditingControl();

		private PropertyGrid OptionsPropertyGrid;

		private DlgIllCalMain.struPastText PastText;

		private struct struPastText
		{
			public struPastText(string txt, int Start, int Length)
			{
				this.Text = txt;
				this.SelStart = Start;
				this.SelLength = Length;
			}

			public string Text;

			public int SelStart;

			public int SelLength;
		}
	}
}
